diff options
author | Anatol Belski <ab@php.net> | 2013-07-10 13:31:22 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2013-07-10 13:31:22 +0200 |
commit | f5b9d87fb95a88333ef7d5bd1f3ee562c8730b6b (patch) | |
tree | 4942449a23795ee17d2ce94c56998a145ed12eca /main/streams/streams.c | |
parent | 73b54b4a5b5e630a20512f08d1d976a2d17948de (diff) | |
parent | 29ac511b8afabaee27133bb3582142a49154eab5 (diff) | |
download | php-git-f5b9d87fb95a88333ef7d5bd1f3ee562c8730b6b.tar.gz |
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
fix possible resource leak and make sure there's something to qsort()
Diffstat (limited to 'main/streams/streams.c')
-rw-r--r-- | main/streams/streams.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c index 623aabff60..823b8859bf 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -2289,6 +2289,7 @@ PHPAPI int _php_stream_scandir(char *dirname, char **namelist[], int flags, php_ } else { if(vector_size*2 < vector_size) { /* overflow */ + php_stream_closedir(stream); efree(vector); return FAILURE; } @@ -2302,6 +2303,7 @@ PHPAPI int _php_stream_scandir(char *dirname, char **namelist[], int flags, php_ nfiles++; if(vector_size < 10 || nfiles == 0) { /* overflow */ + php_stream_closedir(stream); efree(vector); return FAILURE; } @@ -2310,7 +2312,7 @@ PHPAPI int _php_stream_scandir(char *dirname, char **namelist[], int flags, php_ *namelist = vector; - if (compare) { + if (nfiles > 0 && compare) { qsort(*namelist, nfiles, sizeof(char *), (int(*)(const void *, const void *))compare); } return nfiles; |