Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 216e87a

Browse files
committed
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. Closes GH-19715.
1 parent 0e668e5 commit 216e87a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

‎NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ PHP NEWS
5252
deprecation and TidyInternalCategory being available later than
5353
tidyOptGetCategory. (arjendekorte)
5454

55+
- Zip:
56+
. Fix memory leak in zip when encountering empty glob result. (nielsdos)
57+
5558
28 Aug 2025, PHP 8.3.25
5659

5760
- Core:

‎ext/zip/php_zip.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v
668668
can be used for simple glob() calls without further error
669669
checking.
670670
*/
671-
array_init(return_value);
672671
return 0;
673672
}
674673
#endif
@@ -677,7 +676,6 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v
677676

678677
/* now catch the FreeBSD style of "no matches" */
679678
if (!globbuf.gl_pathc || !globbuf.gl_pathv) {
680-
array_init(return_value);
681679
return 0;
682680
}
683681

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /