[php-src] master: Fix OSS-Fuzz #540904105: ASSERT: ast->attr == T_CLASS_C

From: Date: Mon, 21 Sep 2026 17:27:35 +0000
Subject: [php-src] master: Fix OSS-Fuzz #540904105: ASSERT: ast->attr == T_CLASS_C
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141335@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-09-21T19:27:24+02:00 Commit: https://github.com/php/php-src/commit/71d56aa50169f0feed8e2380a56efe307849a813 Raw diff: https://github.com/php/php-src/commit/71d56aa50169f0feed8e2380a56efe307849a813.diff Fix OSS-Fuzz #540904105: ASSERT: ast->attr == T_CLASS_C Closes GH-23769. Changed paths: A Zend/tests/partial_application/oss_fuzz_540904105.phpt M NEWS M Zend/zend_compile.c Diff: diff --git a/NEWS b/NEWS index 69e1b9ade9f7..1a448d35591f 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ PHP NEWS restored). (yqtian-se) . Fixed OSS-Fuzz #538730793 (Assertion failure when returning by-ref from closure invoke). (ndossche) + . Fixed OSS-Fuzz #540904105 (ASSERT: ast->attr == T_CLASS_C). (ndossche) - CLI . Fix GH-22567 (Windows ZTS CLI SAPI should refresh its TSRMLS cache during diff --git a/Zend/tests/partial_application/oss_fuzz_540904105.phpt b/Zend/tests/partial_application/oss_fuzz_540904105.phpt new file mode 100644 index 000000000000..5755c576b4fa --- /dev/null +++ b/Zend/tests/partial_application/oss_fuzz_540904105.phpt @@ -0,0 +1,31 @@ +--TEST-- +OSS-Fuzz #540904105 (ASSERT: ast->attr == T_CLASS_C) +--FILE-- +<?php + +function foo($test, $extra) {} + +const C = foo(__METHOD__, ?); + +var_dump(C); + +?> +--EXPECTF-- +object(Closure)#%d (%d) { + ["name"]=> + string(%d) "%s" + ["file"]=> + string(%d) "%s" + ["line"]=> + int(5) + ["static"]=> + array(1) { + ["test"]=> + string(0) "" + } + ["parameter"]=> + array(1) { + ["$extra"]=> + string(10) "<required>" + } +} diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index f6bff9830bf6..0ced55283868 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -13076,6 +13076,16 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */ zend_eval_const_expr(&ast->child[0]); zend_eval_const_expr(&ast->child[1]); return; + // Only FCC and PFA can appear in constant expressions. + case ZEND_AST_CALL: + case ZEND_AST_STATIC_CALL: + { + zend_ast *args_ast = zend_ast_call_get_args(ast); + if (args_ast && args_ast->kind == ZEND_AST_CALLABLE_CONVERT) { + zend_eval_const_expr(&((zend_ast_fcc *) args_ast)->args); + } + return; + } case ZEND_AST_NAMED_ARG: zend_eval_const_expr(&ast->child[1]); return;

« previous php.cvs (#141335) next »