diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-04-11 01:58:14 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-04-11 01:58:14 -0400 |
commit | dae17a1aaf25d8333e729173d86659066607d87d (patch) | |
tree | 647bba2d6389494ef23af5b735c967f1feca23b2 /src/dirent | |
parent | 52458cfa8c79a9eacb81e151e15cdeff04b75d37 (diff) | |
download | musl-dae17a1aaf25d8333e729173d86659066607d87d.tar.gz musl-dae17a1aaf25d8333e729173d86659066607d87d.tar.bz2 musl-dae17a1aaf25d8333e729173d86659066607d87d.tar.xz musl-dae17a1aaf25d8333e729173d86659066607d87d.zip |
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 (limited to 'src/dirent')
-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; |