mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix assert with attribute + first-class callable in assert
This is going to result in a compile-time error, but AST printing is invoked first and should handle it gracefully. Handle it by falling back to more generic printing code. Fixes oss-fuzz #36264.
This commit is contained in:
11
Zend/tests/first_class_callable_assert2.phpt
Normal file
11
Zend/tests/first_class_callable_assert2.phpt
Normal file
@@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Foo(...) in attribute in assert
|
||||
--FILE--
|
||||
<?php
|
||||
assert(function() {
|
||||
#[Foo(...)]
|
||||
class Test {}
|
||||
});
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Cannot create Closure as attribute argument in %s on line %d
|
||||
@@ -1480,9 +1480,7 @@ static ZEND_COLD void zend_ast_export_class_no_header(smart_str *str, zend_ast_d
|
||||
|
||||
static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast *ast, int indent) {
|
||||
zend_ast_list *list = zend_ast_get_list(ast);
|
||||
uint32_t i, j;
|
||||
|
||||
for (i = 0; i < list->children; i++) {
|
||||
for (uint32_t i = 0; i < list->children; i++) {
|
||||
zend_ast *attr = list->child[i];
|
||||
|
||||
if (i) {
|
||||
@@ -1491,15 +1489,8 @@ static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast *
|
||||
zend_ast_export_ns_name(str, attr->child[0], 0, indent);
|
||||
|
||||
if (attr->child[1]) {
|
||||
zend_ast_list *args = zend_ast_get_list(attr->child[1]);
|
||||
|
||||
smart_str_appendc(str, '(');
|
||||
for (j = 0; j < args->children; j++) {
|
||||
if (j) {
|
||||
smart_str_appends(str, ", ");
|
||||
}
|
||||
zend_ast_export_ex(str, args->child[j], 0, indent);
|
||||
}
|
||||
zend_ast_export_ex(str, attr->child[1], 0, indent);
|
||||
smart_str_appendc(str, ')');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user