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
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011年04月11日 01:58:14 -0400
committerRich Felker <dalias@aerifal.cx>2011年04月11日 01:58:14 -0400
commitdae17a1aaf25d8333e729173d86659066607d87d (patch)
tree647bba2d6389494ef23af5b735c967f1feca23b2
parent52458cfa8c79a9eacb81e151e15cdeff04b75d37 (diff)
downloadmusl-dae17a1aaf25d8333e729173d86659066607d87d.tar.gz
fix errno handling in scandir:
1. saved errno was not being restored, illegally clearing errno to 0. 2. no need to backup and save errno around free; it will not touch except perhaps when the program has already invoked UB...
Diffstat
-rw-r--r--src/dirent/scandir.c 3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/dirent/scandir.c b/src/dirent/scandir.c
index 6a0a9993..aad813ac 100644
--- a/src/dirent/scandir.c
+++ b/src/dirent/scandir.c
@@ -35,12 +35,11 @@ int scandir(const char *path, struct dirent ***res,
closedir(d);
if (errno) {
- old_errno = errno;
if (names) while (cnt-->0) free(names[cnt]);
free(names);
- errno = old_errno;
return -1;
}
+ errno = old_errno;
if (cmp) qsort(names, cnt, sizeof *names, (int (*)(const void *, const void *))cmp);
*res = names;
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月05日 14:30:50 +0000

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