Skip to content

Commit 35f33c6

Browse files
committed
Fix scandir crash with DD_LOCK
1 parent 872619f commit 35f33c6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

newlib/libc/posix/scandir.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,23 @@ scandir(const char *dirname, struct dirent ***namelist,
123123
}
124124
names[numitems++] = p;
125125
}
126+
#ifdef HAVE_DD_LOCK
127+
__lock_release_recursive(dirp->dd_lock);
128+
#endif
126129
closedir(dirp);
127130
if (numitems && dcomp != NULL)
128131
qsort(names, numitems, sizeof(struct dirent *), (void *)dcomp);
129132
*namelist = names;
130-
#ifdef HAVE_DD_LOCK
131-
__lock_release_recursive(dirp->dd_lock);
132-
#endif
133133
return (numitems);
134134

135135
fail:
136136
while (numitems > 0)
137137
free(names[--numitems]);
138138
free(names);
139-
closedir(dirp);
140139
#ifdef HAVE_DD_LOCK
141140
__lock_release_recursive(dirp->dd_lock);
142141
#endif
142+
closedir(dirp);
143143
return (-1);
144144
}
145145

0 commit comments

Comments
 (0)