Skip to content

Commit 81d9a27

Browse files
committed
Fix some leaks in php_scandir
Closes GH-18371.
1 parent bf4b470 commit 81d9a27

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ PHP NEWS
55
- Core:
66
. Fixed bug GH-18304 (Changing the properties of a DateInterval through
77
dynamic properties triggers a SegFault). (nielsdos)
8+
. Fix some leaks in php_scandir. (nielsdos)
89

910
- Filter:
1011
. Fixed bug GH-18309 (ipv6 filter integer overflow). (nielsdos)

main/php_scandir.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ PHPAPI int php_scandir(const char *dirname, struct dirent **namelist[], int (*se
8383

8484
newv = (struct dirent **) realloc (vector, vector_size * sizeof (struct dirent *));
8585
if (!newv) {
86-
return -1;
86+
goto fail;
8787
}
8888
vector = newv;
8989
}
@@ -113,6 +113,7 @@ PHPAPI int php_scandir(const char *dirname, struct dirent **namelist[], int (*se
113113
free(vector[nfiles]);
114114
}
115115
free(vector);
116+
closedir(dirp);
116117
return -1;
117118
}
118119
#endif

0 commit comments

Comments
 (0)