diff options
author | Rich Felker <dalias@aerifal.cx> | 2018-09-16 08:40:46 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2018-09-16 08:46:26 -0400 |
commit | 5cd309f0cc3c92f3fabbaa499652a8329137c4de (patch) | |
tree | d1f0e4855e735f54edb1fbba018c35b59fd4fa13 | |
parent | 5994de4e02a05c19a6bddadcfb687ab2e7511bd6 (diff) | |
download | musl-5cd309f0cc3c92f3fabbaa499652a8329137c4de.tar.gz musl-5cd309f0cc3c92f3fabbaa499652a8329137c4de.tar.bz2 musl-5cd309f0cc3c92f3fabbaa499652a8329137c4de.tar.xz musl-5cd309f0cc3c92f3fabbaa499652a8329137c4de.zip |
fix failure of getdelim to set stream orientation on error
if EINVAL or ENOMEM happened before the first getc_unlocked, it was
possible that the stream orientation had not yet been set.
-rw-r--r-- | src/stdio/getdelim.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/stdio/getdelim.c b/src/stdio/getdelim.c index 26a56780..60c6cc18 100644 --- a/src/stdio/getdelim.c +++ b/src/stdio/getdelim.c @@ -15,6 +15,7 @@ ssize_t getdelim(char **restrict s, size_t *restrict n, int delim, FILE *restric FLOCK(f); if (!n || !s) { + f->mode |= f->mode-1; f->flags |= F_ERR; FUNLOCK(f); errno = EINVAL; @@ -58,6 +59,7 @@ ssize_t getdelim(char **restrict s, size_t *restrict n, int delim, FILE *restric return i; oom: + f->mode |= f->mode-1; f->flags |= F_ERR; FUNLOCK(f); errno = ENOMEM; |