Skip to content

Commit 2753466

Browse files
committed
Fix crash on (unset) cast in constant property initializer
1 parent ec69fbc commit 2753466

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Zend/tests/ast/gh21072.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ try {
1111
echo $e->getMessage();
1212
}
1313
?>
14-
--EXPECT--
15-
Invalid cast in constant expression
14+
--EXPECTF--
15+
Fatal error: The (unset) cast is no longer supported in %s on line %d

Zend/zend_compile.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12565,6 +12565,10 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
1256512565
return;
1256612566
case ZEND_AST_CAST:
1256712567
zend_eval_const_expr(&ast->child[0]);
12568+
if (ast->attr == IS_NULL) {
12569+
zend_error(E_COMPILE_ERROR, "The (unset) cast is no longer supported");
12570+
break;
12571+
}
1256812572
if (ast->child[0]->kind == ZEND_AST_ZVAL
1256912573
&& zend_try_ct_eval_cast(&result, ast->attr, zend_ast_get_zval(ast->child[0]))) {
1257012574
break;

0 commit comments

Comments
 (0)