From 93046609eae6d4c9d57761863cc2bc590a6355e7 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 18 Sep 2025 11:08:36 +0200 Subject: [PATCH 1/4] Fix memory leak in zip when encountering empty glob result From https://github.com/php/php-src/commit/216e87ad7e33fda75f33e31c36a30b04b90e4696 --- php5/php_zip.c | 2 -- php7/php_zip.c | 2 -- php73/php_zip.c | 2 -- php74/php_zip.c | 2 -- php8/php_zip.c | 2 -- php81/php_zip.c | 2 -- php85/php_zip.c | 2 -- 7 files changed, 14 deletions(-) diff --git a/php5/php_zip.c b/php5/php_zip.c index 5dda462..8d16d3b 100644 --- a/php5/php_zip.c +++ b/php5/php_zip.c @@ -706,7 +706,6 @@ int php_zip_glob(char *pattern, int pattern_len, long flags, zval *return_value can be used for simple glob() calls without further error checking. */ - array_init(return_value); return 0; } #endif @@ -715,7 +714,6 @@ int php_zip_glob(char *pattern, int pattern_len, long flags, zval *return_value /* now catch the FreeBSD style of "no matches" */ if (!globbuf.gl_pathc || !globbuf.gl_pathv) { - array_init(return_value); return 0; } diff --git a/php7/php_zip.c b/php7/php_zip.c index bffed61..d962618 100644 --- a/php7/php_zip.c +++ b/php7/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; } diff --git a/php73/php_zip.c b/php73/php_zip.c index 0635a84..eb2c5b6 100644 --- a/php73/php_zip.c +++ b/php73/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; } diff --git a/php74/php_zip.c b/php74/php_zip.c index 0cd33ad..f987056 100644 --- a/php74/php_zip.c +++ b/php74/php_zip.c @@ -664,7 +664,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 @@ -673,7 +672,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; } diff --git a/php8/php_zip.c b/php8/php_zip.c index 5328c25..8129c15 100644 --- a/php8/php_zip.c +++ b/php8/php_zip.c @@ -674,7 +674,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 @@ -683,7 +682,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; } diff --git a/php81/php_zip.c b/php81/php_zip.c index ddcf47f..8bc582d 100644 --- a/php81/php_zip.c +++ b/php81/php_zip.c @@ -676,7 +676,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 @@ -685,7 +684,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; } diff --git a/php85/php_zip.c b/php85/php_zip.c index d5f7b01..604b403 100644 --- a/php85/php_zip.c +++ b/php85/php_zip.c @@ -628,7 +628,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 @@ -637,7 +636,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; } -- 2.51.0