[php-src] master: Merge branch 'PHP-8.6'
| From: | Weilin Du | Date: | Thu, 26 Nov 2026 09:13:52 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-144205@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Date: 2026-11-26T17:07:39+08:00
Commit: https://github.com/php/php-src/commit/dfc29f1dcafc86713df59761e4fb391253d7b206
Raw diff: https://github.com/php/php-src/commit/dfc29f1dcafc86713df59761e4fb391253d7b206.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
Fix GH-25360: ZipArchive assertion when error handler throws at shutdown (#25361)
Changed paths:
A ext/zip/tests/gh25360.phpt
M ext/zip/php_zip.c
Diff:
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 320da1143c63..08fcac6d1fe1 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -649,7 +649,11 @@ static bool php_zipobj_close(ze_zip_object *obj, zend_string **out_str) /* {{{
*
archive->close = true;
int err = zip_close(intern);
if (err) {
- php_error_docref(NULL, E_WARNING, "%s", zip_strerror(intern));
+ zend_try {
+ php_error_docref(NULL, E_WARNING, "%s", zip_strerror(intern));
+ } zend_catch {
+ archive->bailout_callback = true;
+ } zend_end_try();
/* Save error for property reader */
zip_error_t *ziperr = zip_get_error(intern);
obj->err_zip = zip_error_code_zip(ziperr);
@@ -1173,7 +1177,12 @@ bool php_zip_archive_release(php_zip_archive *archive)
int err = zip_close(archive->za);
if (err != 0) {
if (!archive->bailout_callback) {
- php_error_docref(NULL, E_WARNING, "Cannot destroy the zip context: %s",
zip_strerror(archive->za));
+ /* An error handler that throws during shutdown bails out. */
+ zend_try {
+ php_error_docref(NULL, E_WARNING, "Cannot destroy the zip context: %s",
zip_strerror(archive->za));
+ } zend_catch {
+ archive->bailout_callback = true;
+ } zend_end_try();
}
zip_discard(archive->za);
}
diff --git a/ext/zip/tests/gh25360.phpt b/ext/zip/tests/gh25360.phpt
new file mode 100644
index 000000000000..51b297251ece
--- /dev/null
+++ b/ext/zip/tests/gh25360.phpt
@@ -0,0 +1,31 @@
+--TEST--
+GH-25360 (Assertion failure when the error handler throws on the implicit close at shutdown)
+--CREDITS--
+YuanchengJiang
+--EXTENSIONS--
+zip
+--FILE--
+<?php
+$zip = new ZipArchive();
+$zip->open(__DIR__ . '/gh25360.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
+file_put_contents(__DIR__ . '/gh25360.txt', 'contents');
+$zip->addFile(__DIR__ . '/gh25360.txt', 'file.txt');
+unlink(__DIR__ . '/gh25360.txt');
+set_error_handler(function () {
+ throw new Exception('handler');
+});
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+@unlink(__DIR__ . '/gh25360.zip');
+@unlink(__DIR__ . '/gh25360.txt');
+?>
+--EXPECTF--
+Done
+
+Fatal error: Uncaught Exception: handler in %s:%d
+Stack trace:
+#0 [internal function]: {closure:%s:%d}(2, '%s', 'Unknown', 0)
+#1 {main}
+ thrown in %s on line %d