diff --git a/get_next_line_bonus.c b/get_next_line_bonus.c index d92677c..27f119e 100644 --- a/get_next_line_bonus.c +++ b/get_next_line_bonus.c @@ -6,7 +6,7 @@ /* By: cchauvet 1023) + return (NULL); buf2 = stash[fd]; if (ft_strchr(stash[fd], '\n') == -1) { buf1 = ft_getline(fd); buf2 = ft_strfjoin(stash[fd], buf1); - if (buf2 == NULL) - { - free(buf1); - return (NULL); - } } buf1 = ft_getreturn(buf2); stash[fd] = ft_getextra(buf2); - free(buf2); - if (buf1 == NULL) + if (buf1 == NULL || buf2 == NULL) { free(stash[fd]); free(buf1); - return (NULL); } + free(buf2); return (buf1); }