From db20984e9baf42ce9b3e8d0de42d2efe21a05b13 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Sun, 30 Sep 2001 04:55:22 +0000 Subject: Fix nasty behavior difference from glibc -- also fixes getline() -Erik --- libc/stdio/getdelim.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libc/stdio/getdelim.c b/libc/stdio/getdelim.c index 65d5738a1..7cc1f8e84 100644 --- a/libc/stdio/getdelim.c +++ b/libc/stdio/getdelim.c @@ -41,13 +41,12 @@ ssize_t getdelim(char **linebuf, size_t *linebufsz, int delimiter, FILE *file) int ch; int idx = 0; - if ((file == NULL || linebuf==NULL || *linebuf == NULL || *linebufsz == 0) - && !(*linebuf == NULL && *linebufsz ==0 )) { + if (file == NULL || linebuf==NULL || linebufsz == NULL) { __set_errno(EINVAL); return -1; } - if (*linebuf == NULL && *linebufsz == 0){ + if (*linebuf == NULL || *linebufsz < 2) { *linebuf = malloc(GROWBY); if (!*linebuf) { __set_errno(ENOMEM); -- cgit v1.2.3