X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Ffgetln.c;h=5748435d9f6f937c07cd448182df0cc875f0e871;hb=21a172dd36cae7a08492fd3a7500d7bf0daee13e;hp=afe12b5dfe024add1739f80d5982eefef76d7567;hpb=571744447c23f91feb6439948f3a619aca850dfb;p=musl diff --git a/src/stdio/fgetln.c b/src/stdio/fgetln.c index afe12b5d..5748435d 100644 --- a/src/stdio/fgetln.c +++ b/src/stdio/fgetln.c @@ -8,7 +8,7 @@ char *fgetln(FILE *f, size_t *plen) ssize_t l; FLOCK(f); ungetc(getc_unlocked(f), f); - if ((z=memchr(f->rpos, '\n', f->rend - f->rpos))) { + if (f->rend && (z=memchr(f->rpos, '\n', f->rend - f->rpos))) { ret = (char *)f->rpos; *plen = ++z - ret; f->rpos = (void *)z;