From 8eae6833e878683e9b1e6d04e0e182ea8c0f4853 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 4 Sep 2025 22:46:07 +0200 Subject: [PATCH] Fix memory leak in zip when encountering empty glob result The case of returning 0 is inconsistent in when it returns an empty array, furthermore the caller already returns an empty array. Because the caller overwrites the return value in these cases, it can cause a memory leak. This is easier to trigger on master in some cases as different code paths are taken with the new bundled glob. On some platforms it is also triggerable on 8.3. --- ext/zip/php_zip.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 3710b304c3515..9f1d296336e09 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -668,7 +668,6 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v can be used for simple glob() calls without further error checking. */ - array_init(return_value); return 0; } #endif @@ -677,7 +676,6 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v /* now catch the FreeBSD style of "no matches" */ if (!globbuf.gl_pathc || !globbuf.gl_pathv) { - array_init(return_value); return 0; }