Skip to content

Commit

Permalink
hotfix file_to_lines (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
rask24 committed Jun 27, 2024
1 parent 85c62c5 commit 2509e23
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions ft_file/file_to_lines.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: reasuke <reasuke@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/26 18:22:21 by reasuke #+# #+# */
/* Updated: 2024/03/30 15:37:20 by reasuke ### ########.fr */
/* Updated: 2024/06/28 02:40:47 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -58,19 +58,16 @@ static int _fill_lines(char **lines, int n, char *file_path)
while (n--)
{
line = get_next_line(fd);
if (!line)
if (errno)
{
ft_free_strs(lines);
close(fd);
if (errno != 0)
{
ft_free_strs(lines);
return (ERROR);
}
break ;
return (ERROR);
}
*lines++ = line;
}
*lines = NULL;
close(fd);
return (OK);
}

Expand Down

0 comments on commit 2509e23

Please sign in to comment.