Prevent fd leak in readdir_r that causes false negative on readdir_r implementation when compiled with AddressSanitizer

This commit is contained in:
Ondřej Surý 2017-01-10 10:21:54 +01:00 committed by Joe Watkins
parent 125ee6a68e
commit 1bdffee820
No known key found for this signature in database
GPG key ID: F9BA0ADA31CBD89E

View file

@ -1376,8 +1376,11 @@ main() {
dir = opendir("/");
if (!dir)
exit(1);
if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0) {
close(dir);
exit(0);
}
close(dir);
exit(1);
}
],[