From 8bf47fcdf2da7f7a9b896676c119429bc7d0b4ff Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 14 Dec 2019 20:00:01 -0600 Subject: Bugfix: xgetline() wasn't returning NULL at EOF. --- lib/xwrap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/xwrap.c b/lib/xwrap.c index cfd17219..2f47ac66 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -1066,13 +1066,14 @@ char *xgetline(FILE *fp, int *len) { char *new = 0; size_t linelen = 0; + long ll; errno = 0; - if (1>(linelen = getline(&new, &linelen, fp))) { + if (1>(ll = getline(&new, &linelen, fp))) { if (errno) perror_msg("getline"); new = 0; } else if (new[linelen-1] == '\n') new[--linelen] = 0; - if (len) *len = linelen; + if (len) *len = ll; return new; } -- cgit v1.2.3