projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0770962
)
fix getdelim to set the error indicator on all failures
author
Szabolcs Nagy
<nsz@port70.net>
Sat, 4 Apr 2015 11:27:06 +0000
(11:27 +0000)
committer
Rich Felker
<dalias@aerifal.cx>
Sat, 4 Apr 2015 14:53:09 +0000
(10:53 -0400)
src/stdio/getdelim.c
patch
|
blob
|
history
diff --git
a/src/stdio/getdelim.c
b/src/stdio/getdelim.c
index 26093a6cfa02a358c1a50e6e59ac618d8920d86e..a88c3933f86d55e007647c2a05a370b4afaaa0a6 100644
(file)
--- a/
src/stdio/getdelim.c
+++ b/
src/stdio/getdelim.c
@@
-13,15
+13,17
@@
ssize_t getdelim(char **restrict s, size_t *restrict n, int delim, FILE *restric
size_t i=0;
int c;
+ FLOCK(f);
+
if (!n || !s) {
+ f->flags |= F_ERR;
+ FUNLOCK(f);
errno = EINVAL;
return -1;
}
if (!*s) *n=0;
- FLOCK(f);
-
for (;;) {
z = memchr(f->rpos, delim, f->rend - f->rpos);
k = z ? z - f->rpos + 1 : f->rend - f->rpos;
@@
-56,6
+58,7
@@
ssize_t getdelim(char **restrict s, size_t *restrict n, int delim, FILE *restric
return i;
oom:
+ f->flags |= F_ERR;
FUNLOCK(f);
errno = ENOMEM;
return -1;