Skip to content

Fix GH-21698: memory leak in ZipArchive::addGlob on early returns.#21702

Closed
devnexen wants to merge 2 commits intophp:PHP-8.4from
devnexen:gh21698
Closed

Fix GH-21698: memory leak in ZipArchive::addGlob on early returns.#21702
devnexen wants to merge 2 commits intophp:PHP-8.4from
devnexen:gh21698

Conversation

@devnexen
Copy link
Copy Markdown
Member

globfree was not called on the no-matches path and on the open_basedir reject path, leaking the glob_t contents populated by a successful glob() call.

globfree was not called on the no-matches path and on the
open_basedir reject path, leaking the glob_t contents populated by a
successful glob() call.
@devnexen devnexen marked this pull request as ready for review April 10, 2026 07:41
@devnexen devnexen closed this in 391ec27 Apr 10, 2026
iliaal added a commit to iliaal/php-src that referenced this pull request Apr 10, 2026
phpGH-21702 added two `globfree()` calls at the no-match and open_basedir
reject paths, but called `globfree` directly instead of the `php_globfree`
wrapper used at the success path below. On systems where `<glob.h>` isn't
transitively included, the build breaks with
`-Werror=implicit-function-declaration`.

Match the existing wrapper usage at line 715.
iliaal added a commit to iliaal/php-src that referenced this pull request Apr 10, 2026
phpGH-21702 added two `globfree()` calls at the no-match and open_basedir
reject paths, but called `globfree` directly instead of the `php_globfree`
wrapper used at the success path below. PHP-8.5 dropped the direct
`<glob.h>` include from `ext/zip/php_zip.c` in favor of the `php_glob.h`
wrapper, so the build now breaks with
`-Werror=implicit-function-declaration` on systems where `<glob.h>` isn't
transitively included.

Match the existing wrapper usage at line 675.
devnexen pushed a commit that referenced this pull request Apr 10, 2026
GH-21702 added two `globfree()` calls at the no-match and open_basedir
reject paths, but called `globfree` directly instead of the `php_globfree`
wrapper used at the success path below. PHP-8.5 dropped the direct
`<glob.h>` include from `ext/zip/php_zip.c` in favor of the `php_glob.h`
wrapper, so the build now breaks with
`-Werror=implicit-function-declaration` on systems where `<glob.h>` isn't
transitively included.

Match the existing wrapper usage at line 675.

close GH-21709
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants