musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/stdio
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2015年04月04日 11:27:06 +0000
committerRich Felker <dalias@aerifal.cx>2015年04月04日 10:53:09 -0400
commit05e0e301e3efbeb399b9f3d96fab63aac18e601a (patch)
tree702dc7b90569f792378c93001584dff35a12993d /src/stdio
parent077096259dafe6703d40f2265bad0819c24bfb12 (diff)
downloadmusl-05e0e301e3efbeb399b9f3d96fab63aac18e601a.tar.gz
fix getdelim to set the error indicator on all failures
Diffstat (limited to 'src/stdio')
-rw-r--r--src/stdio/getdelim.c 7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/stdio/getdelim.c b/src/stdio/getdelim.c
index 26093a6c..a88c3933 100644
--- 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;
generated by cgit v1.2.1 (git 2.18.0) at 2025年10月04日 18:57:01 +0000

AltStyle によって変換されたページ (->オリジナル) /