Skip to content

Commit

Permalink
Fix scandir DD_LOCK
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtrujy committed May 16, 2024
1 parent efac6d4 commit 015584b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions newlib/libc/posix/scandir.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,23 @@ scandir(const char *dirname, struct dirent ***namelist,
}
names[numitems++] = p;
}
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
closedir(dirp);
if (numitems && dcomp != NULL)
qsort(names, numitems, sizeof(struct dirent *), (void *)dcomp);
*namelist = names;
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return (numitems);

fail:
while (numitems > 0)
free(names[--numitems]);
free(names);
closedir(dirp);
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
closedir(dirp);
return (-1);
}

Expand Down

0 comments on commit 015584b

Please sign in to comment.