From 9a86d4212da89839d51b6ed1bec23938fa728046 Mon Sep 17 00:00:00 2001 From: Max Rees Date: Fri, 27 Mar 2020 12:57:24 -0500 Subject: [PATCH] ext/zip: don't use gl_pathc after call to globfree (#79424) This breaks on Linux with the musl libc, since it zeroes out gl_pathc during globfree. --- NEWS | 2 ++ ext/zip/php_zip.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index edd69bb27a95e..f27238b701428 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,8 @@ PHP NEWS - Zip: . Fixed Bug #79296 (ZipArchive::open fails on empty file). (Remi) + . Fixed bug #79424 (php_zip_glob uses gl_pathc after call to globfree). + (Max Rees) 19 Mar 2020, PHP 7.3.16 diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 48af712b9c23b..9cbef052853b9 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -606,8 +606,9 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v add_next_index_string(return_value, globbuf.gl_pathv[n]+cwd_skip); } + ret = globbuf.gl_pathc; globfree(&globbuf); - return globbuf.gl_pathc; + return ret; #else zend_throw_error(NULL, "Glob support is not available"); return 0;