X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fstdio%2Ffgetln.c;h=5748435d9f6f937c07cd448182df0cc875f0e871;hb=e1a51185ceb4386481491e11f6dd39569b9e54f7;hp=06b8883756e4356f3a0cb96c8d412c9db58b031c;hpb=2d93d6446191def352b8913e859d6104f1398c72;p=musl diff --git a/src/stdio/fgetln.c b/src/stdio/fgetln.c index 06b88837..5748435d 100644 --- a/src/stdio/fgetln.c +++ b/src/stdio/fgetln.c @@ -1,4 +1,6 @@ +#define _GNU_SOURCE #include "stdio_impl.h" +#include char *fgetln(FILE *f, size_t *plen) { @@ -6,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;