diff options
author | Rob Landley <rob@landley.net> | 2019-12-14 20:00:01 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-12-14 20:00:01 -0600 |
commit | 8bf47fcdf2da7f7a9b896676c119429bc7d0b4ff (patch) | |
tree | c1a078f4423483f5d9dc562fed2fab5c28b7eedf /lib | |
parent | 08b5330e2bbdfe5b79e7571c3bf242c7befe96bd (diff) | |
download | toybox-8bf47fcdf2da7f7a9b896676c119429bc7d0b4ff.tar.gz |
Bugfix: xgetline() wasn't returning NULL at EOF.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/xwrap.c | 5 |
1 files changed, 3 insertions, 2 deletions
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; } |