Skip to content

Commit b9a5bfc

Browse files
nielsdosiluuu1994
authored andcommitted
Fix GH-10570: Assertion `(key)->h != 0 && "Hash must be known"' failed.
Fixes GH-10570, see GH-10570 for analysis. Closes GH-10572
1 parent 8959ff3 commit b9a5bfc

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ PHP NEWS
1414
. Fixed language scanner generation build. (Daniel Black)
1515
. Fixed zend_update_static_property() calling zend_update_static_property_ex()
1616
misleadingly with the wrong return type. (nielsdos)
17+
. Fixed unknown string hash on property fetch with integer constant name.
18+
(nielsdos)
1719

1820
- Curl:
1921
. Fixed deprecation warning at compile time. (Max Kellermann)

Zend/tests/gh10570.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
GH-10570 (Assertion `(key)->h != 0 && "Hash must be known"' failed.): constant variation
3+
--FILE--
4+
<?php
5+
$a = new stdClass();
6+
for ($i = 0; $i < 2; $i++) {
7+
$a->{90};
8+
$a->{0} = 0;
9+
}
10+
?>
11+
--EXPECTF--
12+
Warning: Undefined property: stdClass::$90 in %s on line %d
13+
14+
Warning: Undefined property: stdClass::$90 in %s on line %d

Zend/zend_compile.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,6 +2924,7 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t
29242924
opline = zend_delayed_emit_op(result, ZEND_FETCH_OBJ_R, &obj_node, &prop_node);
29252925
if (opline->op2_type == IS_CONST) {
29262926
convert_to_string(CT_CONSTANT(opline->op2));
2927+
zend_string_hash_val(Z_STR_P(CT_CONSTANT(opline->op2)));
29272928
opline->extended_value = zend_alloc_cache_slots(3);
29282929
}
29292930

0 commit comments

Comments
 (0)