+#define _GNU_SOURCE
#include "stdio_impl.h"
#include <string.h>
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;