Skip to content

Commit 1bdffee

Browse files
oerdnjkrakjoe
authored andcommitted
Prevent fd leak in readdir_r that causes false negative on readdir_r implementation when compiled with AddressSanitizer
1 parent 125ee6a commit 1bdffee

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

acinclude.m4

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,8 +1376,11 @@ main() {
13761376
dir = opendir("/");
13771377
if (!dir)
13781378
exit(1);
1379-
if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
1379+
if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0) {
1380+
close(dir);
13801381
exit(0);
1382+
}
1383+
close(dir);
13811384
exit(1);
13821385
}
13831386
],[

0 commit comments

Comments
 (0)