[php-src] master: Fix OSS-Fuzz #538730793: Assertion failure when returning by-ref from closure invoke

From: Date: Mon, 21 Sep 2026 17:24:38 +0000
Subject: [php-src] master: Fix OSS-Fuzz #538730793: Assertion failure when returning by-ref from closure invoke
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141334@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-09-21T19:24:25+02:00 Commit: https://github.com/php/php-src/commit/762fdd56c9b7c3a335ddddb79cd326ac6962f676 Raw diff: https://github.com/php/php-src/commit/762fdd56c9b7c3a335ddddb79cd326ac6962f676.diff Fix OSS-Fuzz #538730793: Assertion failure when returning by-ref from closure invoke Forgot one place in this file where we have to unwrap the reference, the zend_closure_call_magic function had this already but the invoke was missing. Closes GH-23787. Changed paths: A Zend/tests/closures/oss_fuzz_538730793.phpt M NEWS M Zend/zend_closures.c Diff: diff --git a/NEWS b/NEWS index 9e8da51adbbe..69e1b9ade9f7 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ PHP NEWS . Fixed bug GH-23752 (Use scoped diagnostic suppression for the global register declarations so the caller's -Wvolatile-register-var state is restored). (yqtian-se) + . Fixed OSS-Fuzz #538730793 (Assertion failure when returning by-ref from + closure invoke). (ndossche) - CLI . Fix GH-22567 (Windows ZTS CLI SAPI should refresh its TSRMLS cache during diff --git a/Zend/tests/closures/oss_fuzz_538730793.phpt b/Zend/tests/closures/oss_fuzz_538730793.phpt new file mode 100644 index 000000000000..e5347a03ee90 --- /dev/null +++ b/Zend/tests/closures/oss_fuzz_538730793.phpt @@ -0,0 +1,13 @@ +--TEST-- +OSS-Fuzz #538730793 (Assertion failure when returning by-ref from closure invoke) +--FILE-- +<?php + +$x = function&(){}; +$y = $x->__invoke(); +var_dump($y); + +?> +--EXPECTF-- +Notice: Only variable references should be returned by reference in %s on line %d +NULL diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 788957d1c3a0..d4c0b5881369 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -74,6 +74,7 @@ ZEND_METHOD(Closure, __invoke) /* {{{ */ zend_closure_get_closure(Z_OBJ_P(ZEND_THIS), &fcc.calling_scope, &fcc.function_handler, &fcc.object, false); fcc.called_scope = fcc.calling_scope; zend_call_known_fcc(&fcc, return_value, num_args, args, named_args); + zend_return_unwrap_ref(execute_data, return_value); /* destruct the function also, then - we have allocated it in get_method */ zend_string_release_ex(func->internal_function.function_name, 0);

« previous php.cvs (#141334) next »