mirror of
git://git.musl-libc.org/musl
synced 2025-02-25 07:10:22 +00:00
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...
This commit is contained in:
parent
52458cfa8c
commit
dae17a1aaf
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user