Skip to content

Commit b964d00

Browse files
committed
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.
1 parent 0798443 commit b964d00

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
new class(...) in assert
3+
--FILE--
4+
<?php
5+
6+
assert(new class(...) {});
7+
8+
?>
9+
--EXPECTF--
10+
Fatal error: Cannot create Closure for new expression in %s on line %d

Zend/zend_ast.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,8 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
20362036
zend_ast_export_attributes(str, decl->child[3], indent, 0);
20372037
}
20382038
smart_str_appends(str, "class");
2039-
if (zend_ast_get_list(ast->child[1])->children) {
2039+
if (!zend_ast_is_list(ast->child[1])
2040+
|| zend_ast_get_list(ast->child[1])->children) {
20402041
smart_str_appendc(str, '(');
20412042
zend_ast_export_ex(str, ast->child[1], 0, indent);
20422043
smart_str_appendc(str, ')');

0 commit comments

Comments
 (0)