From 015584ba7607367d884757b4babc8b76904002e0 Mon Sep 17 00:00:00 2001 From: Francisco Javier Trujillo Mata Date: Thu, 16 May 2024 00:25:03 +0200 Subject: [PATCH] Fix scandir DD_LOCK --- newlib/libc/posix/scandir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/newlib/libc/posix/scandir.c b/newlib/libc/posix/scandir.c index 7fd008910e..fb3efa387b 100644 --- a/newlib/libc/posix/scandir.c +++ b/newlib/libc/posix/scandir.c @@ -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); }