Skip to content

Commit c4d4cea

Browse files
committed
zip: Fix name leaks when path length check fails in php_zip_pcre()
The loop isn't continued, so the remaining names will not get freed if we don't do an extra loop here.
1 parent 4c54dce commit c4d4cea

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

ext/zip/php_zip.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,10 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val
790790
if ((path_len + namelist_len + 1) >= MAXPATHLEN) {
791791
php_error_docref(NULL, E_WARNING, "add_path string too long (max: %u, %zu given)",
792792
MAXPATHLEN - 1, (path_len + namelist_len + 1));
793-
zend_string_release_ex(namelist[i], 0);
793+
/* The loop isn't continued, so all remaining file names must get freed. */
794+
for (; i < files_cnt; i++) {
795+
zend_string_release_ex(namelist[i], false);
796+
}
794797
break;
795798
}
796799

0 commit comments

Comments
 (0)