Skip to content

Commit 0801c56

Browse files
nielsdosarnaud-lb
authored andcommittedJan 20, 2023
Fix GH-10248: Assertion `!(zval_get_type(&(*(property))) == 10)' failed.
The assertion failure was triggered in a debug code-path that validates property types for internal classes. zend_verify_internal_read_property_type was called with retval being a reference, which is not allowed because that function eventually calls to i_zend_check_property_type, which does not expect a reference. The non-debug code-path already takes into account that retval can be a reference, as it optionally dereferences retval. Add a dereference in zend_verify_internal_read_property_type just before the call to zend_verify_property_type, which is how other callers often behave as well.
1 parent ce877da commit 0801c56

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
 

‎Zend/zend_execute.c

+1
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,7 @@ static void zend_verify_internal_read_property_type(zend_object *obj, zend_strin
12071207
zend_property_info *prop_info =
12081208
zend_get_property_info(obj->ce, name, /* silent */ true);
12091209
if (prop_info && prop_info != ZEND_WRONG_PROPERTY_INFO && ZEND_TYPE_IS_SET(prop_info->type)) {
1210+
ZVAL_OPT_DEREF(val);
12101211
zend_verify_property_type(prop_info, val, /* strict */ true);
12111212
}
12121213
}

‎ext/spl/tests/gh10248.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
GH-10248 (Assertion `!(zval_get_type(&(*(property))) == 10)' failed.)
3+
--FILE--
4+
<?php
5+
6+
class a extends ArrayIterator
7+
{
8+
public ?int $property;
9+
}
10+
$a = new a();
11+
$a->property = &$b;
12+
$a->property;
13+
14+
echo "Done\n";
15+
16+
?>
17+
--EXPECT--
18+
Done

0 commit comments

Comments
 (0)