projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix popen not to leak pipes from one child to another
[musl]
/
src
/
stdio
/
fgetln.c
diff --git
a/src/stdio/fgetln.c
b/src/stdio/fgetln.c
index
06b8883
..
5748435
100644
(file)
--- a/
src/stdio/fgetln.c
+++ b/
src/stdio/fgetln.c
@@
-1,4
+1,6
@@
+#define _GNU_SOURCE
#include "stdio_impl.h"
#include "stdio_impl.h"
+#include <string.h>
char *fgetln(FILE *f, size_t *plen)
{
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);
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;
ret = (char *)f->rpos;
*plen = ++z - ret;
f->rpos = (void *)z;