Fix AST print of first class callable in anon class expr

This will cause a compile error later, but the expression is
printed first.

Fixes oss-fuzz #37473.
This commit is contained in:
Nikita Popov 2021-08-26 11:58:31 +02:00
parent 07984435ae
commit b964d007e3
2 changed files with 12 additions and 1 deletions

View File

@ -0,0 +1,10 @@
--TEST--
new class(...) in assert
--FILE--
<?php
assert(new class(...) {});
?>
--EXPECTF--
Fatal error: Cannot create Closure for new expression in %s on line %d

View File

@ -2036,7 +2036,8 @@ simple_list:
zend_ast_export_attributes(str, decl->child[3], indent, 0);
}
smart_str_appends(str, "class");
if (zend_ast_get_list(ast->child[1])->children) {
if (!zend_ast_is_list(ast->child[1])
|| zend_ast_get_list(ast->child[1])->children) {
smart_str_appendc(str, '(');
zend_ast_export_ex(str, ast->child[1], 0, indent);
smart_str_appendc(str, ')');