Commit 37bff59776d for php
commit 37bff59776d277de58179224e09f28ce3a404912
Merge: 2d9a5c7cfa9 b882019d155
Author: Weilin Du <weilindu@php.net>
Date: Tue Dec 1 03:37:55 2026 +0800
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
Fix fd leak in compress.zlib:// when gzdopen() fails (#25794)
diff --cc NEWS
index 3f9ab4f6549,19324a39fd4..fe7af229277
--- a/NEWS
+++ b/NEWS
@@@ -354,17 -319,33 +354,21 @@@ PH
. Fixed a crash in XSLTProcessor::transformToDoc() when the return class
cannot be instantiated. (Ilia Alshanetsky)
+- Zip:
+ . Fixed bug GH-25360 (ZipArchive assertion when an error handler throws
+ on implicit close at shutdown). (lazerg)
+
+ - Zlib:
+ . Fixed a file descriptor leak when opening a compress.zlib:// stream
+ fails. (lacatoire)
+
-19 Nov 2026, PHP 8.5.13
+19 Nov 2026, PHP 8.6.0
- Core:
- . Fixed bug GH-24184 (System ID not being reinitialized after an Apache
- graceful restart, potentially causing incompatible OPcache file cache
- entries to be reused). (Levi Morrison)
- . Fixed memory leak when an exception already contains the pending exception
- in its previous chain. (Edmond)
- . Fixed bug GH-23979 (Nullsafe operator must not flush delayed oplines of an
- enclosing function). (ndossche)
- . Fixed memory manager keeping a block reallocated to exactly the size of
- the next smaller bin in its larger bin, which efree_size() then freed
- into the wrong one. (Marc Bennewitz)
- . Fixed bug GH-24081 (User opcode handlers resume execution against a stale
- frame under ZEND_VM_KIND_TAILCALL). (devnexen)
- . Fixed bug GH-24218 (Invalid opcode for count() of a literal array
- without SCCP). (lazerg)
- . Fix throwing behaviour with recursive arrays in VM. (ndossche)
- . Fixed skipped catch block when switching fibers during exception unwinding
- (Nicolas Grekas)
- . Fix escape analysis for objects implementing ArrayAccess. (ndossche, Arnaud)
- . Fix UAF for resolved callable zval. (EdmondDantes)
- . Fix memory leak for nested HTTP calls. (EdmondDantes)
+ . Fixed array_map() optimization not resolving the function name of an FCC.
+ (ChrisAbner)
+ . Fix potential ABI incompatibility when adding fields in patches by adding
+ padding to globals. (ilutov)
. Fix function and constant imports in compile_to_ast and add support
for grouping. (Klaas Skelte van der Werf)
. Fixed bug GH-24668 (zend_set_local_var() leaks the previous value of an
diff --cc ext/zlib/zlib_fopen_wrapper.c
index 47df3191789,468bee7f7c8..475520a7841
--- a/ext/zlib/zlib_fopen_wrapper.c
+++ b/ext/zlib/zlib_fopen_wrapper.c
@@@ -201,23 -202,16 +201,25 @@@ php_stream *php_stream_gzopen(php_strea
php_socket_t fd;
if (SUCCESS == php_stream_cast(innerstream, PHP_STREAM_AS_FD, (void **) &fd, REPORT_ERRORS)) {
+ int gz_fd = dup(fd);
+
- self = emalloc(sizeof(*self));
+ struct php_gz_stream_data_t *self = emalloc(sizeof(*self));
self->stream = innerstream;
- self->gz_file = gzdopen(dup(fd), mode);
+ self->gz_file = gzdopen(gz_fd, mode);
if (self->gz_file) {
- zval *zlevel = context ? php_stream_context_get_option(context, "zlib", "level") : NULL;
- if (zlevel && (Z_OK != gzsetparams(self->gz_file, zval_get_long(zlevel), Z_DEFAULT_STRATEGY))) {
- php_error(E_WARNING, "failed setting compression level");
+ const zval *zlevel = context ? php_stream_context_get_option(context, "zlib", "level") : NULL;
+
+ if (zlevel) {
+ bool failed = true;
+ const zend_long level = zval_try_get_long(zlevel, &failed);
+ if (UNEXPECTED(failed)) {
+ php_stream_wrapper_log_warn(wrapper, context, REPORT_ERRORS, InvalidParam,
+ "zlib \"level\" context option must be of type int, %s given", zend_zval_type_name(zlevel));
+ } else if (Z_OK != gzsetparams(self->gz_file, level, Z_DEFAULT_STRATEGY)) {
+ php_stream_wrapper_log_warn(wrapper, context, REPORT_ERRORS, Generic,
+ "failed setting compression level");
+ }
}
stream = php_stream_alloc_rel(&php_stream_gzio_ops, self, 0, mode);