mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix crash on (unset) cast in constant expression
Fixes GH-21072 Closes GH-21073
This commit is contained in:
2
NEWS
2
NEWS
@@ -5,6 +5,8 @@ PHP NEWS
|
||||
- Core:
|
||||
. Fixed bug GH-21029 (zend_mm_heap corrupted on Aarch64, LTO builds). (Arnaud)
|
||||
. Fixed bug GH-21059 (Segfault when preloading constant AST closure). (ilutov)
|
||||
. Fixed bug GH-21072 (Crash on (unset) cast in constant expression).
|
||||
(arshidkv12)
|
||||
|
||||
- Windows:
|
||||
. Fixed compilation with clang (missing intrin.h include). (Kévin Dunglas)
|
||||
|
||||
17
Zend/tests/ast/gh21072.phpt
Normal file
17
Zend/tests/ast/gh21072.phpt
Normal file
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
(unset) cast must not be allowed in constant expressions
|
||||
--CREDITS--
|
||||
Viet Hoang Luu (@vi3tL0u1s)
|
||||
--FILE--
|
||||
<?php
|
||||
try {
|
||||
class C {
|
||||
public $p = (unset) C::class;
|
||||
}
|
||||
new C;
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: The (unset) cast is no longer supported in %s on line %d
|
||||
@@ -12360,6 +12360,9 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
|
||||
zend_eval_const_expr(&ast->child[1]);
|
||||
return;
|
||||
case ZEND_AST_CAST:
|
||||
if (ast->attr == IS_NULL) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "The (unset) cast is no longer supported");
|
||||
}
|
||||
zend_eval_const_expr(&ast->child[0]);
|
||||
if (ast->child[0]->kind == ZEND_AST_ZVAL
|
||||
&& zend_try_ct_eval_cast(&result, ast->attr, zend_ast_get_zval(ast->child[0]))) {
|
||||
|
||||
Reference in New Issue
Block a user