1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

Fix property fetch on magic constants in constant expressions

Closes GH-9136
Closes GH-9138
Closes GH-9172
This commit is contained in:
Ilija Tovilo
2022-07-28 10:40:10 +02:00
parent b576bb901e
commit 966d22b1bd
4 changed files with 27 additions and 0 deletions

2
NEWS
View File

@@ -62,6 +62,8 @@ PHP NEWS
(Tobias Bachert)
. Added error_log_mode ini setting. (Mikhail Galanin)
. Updated request startup messages. (Eric Norris)
. Fixed GH-9136 and GH-9138 (Fixed fetching property of magic constant in
constant expressions). (ilutov)
- COM:
. Fixed bug GH-8750 (Can not create VT_ERROR variant type). (cmb)

10
Zend/tests/gh9136.phpt Normal file
View File

@@ -0,0 +1,10 @@
--TEST--
GH-9136: Assertion when fetching property of magic constant in constant expression
--FILE--
<?php
const C = __file__->foo;
?>
--EXPECTF--
Warning: Attempt to read property "foo" on string in %s on line %d

11
Zend/tests/gh9138.phpt Normal file
View File

@@ -0,0 +1,11 @@
--TEST--
GH-9138: NULL pointer dereference when fetching property of "bad" list in constant expression
--FILE--
<?php
#[Attribute([,]->e)]
class Foo {}
?>
--EXPECTF--
Fatal error: Cannot use empty array elements in arrays in %s on line %d

View File

@@ -10616,6 +10616,10 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
case ZEND_AST_CONST_ENUM_INIT:
zend_eval_const_expr(&ast->child[2]);
return;
case ZEND_AST_PROP:
zend_eval_const_expr(&ast->child[0]);
zend_eval_const_expr(&ast->child[1]);
return;
default:
return;
}