From 38ce8029e589d6c70fe387ecfaa6a3219c63d3de Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Wed, 23 Nov 2022 15:28:59 +0100 Subject: [PATCH] fd > 1024 fix --- get_next_line_bonus.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) 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); }