Commit 5534bb74c87 for php
commit 5534bb74c87ec3f96a8070dd2e8c3915c3343096
Merge: b35fed72f46 cfe29b5e13f
Author: Weilin Du <weilindu@php.net>
Date: Sat Nov 28 16:22:41 2026 +0800
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
Fix stream context functions rejecting options held by reference (#25719)
diff --cc NEWS
index d3e2d045a55,574b593c5fe..6b75398ec27
--- a/NEWS
+++ b/NEWS
@@@ -281,8 -284,10 +281,10 @@@ PH
user filter). (Edmond)
. Fixed bug GH-15701 (Build failure: incompatible funopen() seeker pointer
type on 32-bit platforms). (Kamil Tekiela)
- . Fixed bug GH-25464 (Segfault reading from php://memory after
- stream_filter_remove() on a read filter). (David Carlier)
+ . Fixed bug GH-25586 (Use-after-free in php_stream_cast() when a userspace
+ stream_flush() closes the stream). (lazerg)
+ . Fixed stream_context_create() and stream_context_set_params() rejecting
+ an options array passed by reference in the context parameters. (lacatoire)
- XSL:
. Fixed a crash in XSLTProcessor::transformToDoc() when the return class
diff --cc ext/standard/streamsfuncs.c
index 068794701f3,7f10a56136c..f2d611f72dd
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@@ -904,22 -947,12 +904,22 @@@ static zend_result parse_context_params
context->notifier = NULL;
}
+ zend_fcall_info_cache *fcc = emalloc(sizeof(*fcc));
+ char *error;
+ if (!zend_is_callable_ex(tmp, NULL, 0, NULL, fcc, &error)) {
+ zend_argument_type_error(1, "must be an array with valid callbacks as values, %s", error);
+ efree(fcc);
+ efree(error);
+ return FAILURE;
+ }
+ zend_fcc_addref(fcc);
+
context->notifier = php_stream_notification_alloc();
context->notifier->func = user_space_stream_notifier;
- ZVAL_COPY(&context->notifier->ptr, tmp);
+ context->notifier->ptr = fcc;
context->notifier->dtor = user_space_stream_notifier_dtor;
}
- if (NULL != (tmp = zend_hash_str_find(params, "options", sizeof("options")-1))) {
+ if (NULL != (tmp = zend_hash_str_find_deref(params, "options", sizeof("options")-1))) {
if (Z_TYPE_P(tmp) == IS_ARRAY) {
return parse_context_options(context, Z_ARRVAL_P(tmp));
} else {