Skip to content

Commit ee4a9a4

Browse files
committedMar 2, 2025
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-17736: Assertion failure zend_reference_destroy()
2 parents 4936c32 + ce8ab5f commit ee4a9a4

File tree

11 files changed

+39
-1
lines changed

11 files changed

+39
-1
lines changed
 

‎NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ PHP NEWS
1212
. Fixed bug GH-17913 (ReflectionFunction::isDeprecated() returns incorrect
1313
results for closures created from magic __call()). (timwolla)
1414

15+
- Treewide:
16+
. Fixed bug GH-17736 (Assertion failure zend_reference_destroy()). (nielsdos)
17+
1518
27 Feb 2025, PHP 8.4.5
1619

1720
- BCMath:

‎Zend/zend_execute.c

+3
Original file line numberDiff line numberDiff line change
@@ -3424,6 +3424,9 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
34243424
return;
34253425
}
34263426
}
3427+
} else if (prop_op_type == IS_CONST) {
3428+
/* CE mismatch, make cache slot consistent */
3429+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
34273430
}
34283431

34293432
/* Pointer on property callback is required */

‎ext/date/php_date.c

+1
Original file line numberDiff line numberDiff line change
@@ -4618,6 +4618,7 @@ static zval *date_interval_get_property_ptr_ptr(zend_object *object, zend_string
46184618
zend_string_equals_literal(name, "days") ||
46194619
zend_string_equals_literal(name, "invert") ) {
46204620
/* Fallback to read_property. */
4621+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
46214622
ret = NULL;
46224623
} else {
46234624
ret = zend_std_get_property_ptr_ptr(object, name, type, cache_slot);

‎ext/dom/php_dom.c

+1
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ static zval *dom_get_property_ptr_ptr(zend_object *object, zend_string *name, in
362362
return zend_std_get_property_ptr_ptr(object, name, type, cache_slot);
363363
}
364364

365+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
365366
return NULL;
366367
}
367368

‎ext/pdo/pdo_stmt.c

+1
Original file line numberDiff line numberDiff line change
@@ -2491,6 +2491,7 @@ static zval *pdo_row_get_property_ptr_ptr(zend_object *object, zend_string *name
24912491
ZEND_IGNORE_VALUE(type);
24922492
ZEND_IGNORE_VALUE(cache_slot);
24932493

2494+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
24942495
return NULL;
24952496
}
24962497

‎ext/simplexml/simplexml.c

+2
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,8 @@ static zval *sxe_property_get_adr(zend_object *object, zend_string *zname, int f
639639
SXE_ITER type;
640640
zval member;
641641

642+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
643+
642644
sxe = php_sxe_fetch_object(object);
643645
GET_NODE(sxe, node);
644646
if (UNEXPECTED(!node)) {

‎ext/simplexml/tests/gh17736.phpt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-17736 (Assertion failure zend_reference_destroy())
3+
--EXTENSIONS--
4+
simplexml
5+
--FILE--
6+
<?php
7+
$o1 = new SimpleXMLElement('<a/>');
8+
class C {
9+
public int $a = 1;
10+
}
11+
function test($obj) {
12+
$ref =& $obj->a;
13+
}
14+
$obj = new C;
15+
test($obj);
16+
test($o1);
17+
echo "Done\n";
18+
?>
19+
--EXPECT--
20+
Done

‎ext/snmp/snmp.c

+1
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,7 @@ static zval *php_snmp_get_property_ptr_ptr(zend_object *object, zend_string *nam
18611861
return zend_std_get_property_ptr_ptr(object, name, type, cache_slot);
18621862
}
18631863

1864+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
18641865
return NULL;
18651866
}
18661867

‎ext/spl/spl_array.c

+2
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,8 @@ static zval *spl_array_get_property_ptr_ptr(zend_object *object, zend_string *na
861861

862862
if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
863863
&& !zend_std_has_property(object, name, ZEND_PROPERTY_EXISTS, NULL)) {
864+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
865+
864866
/* If object has offsetGet() overridden, then fallback to read_property,
865867
* which will call offsetGet(). */
866868
zval member;

‎ext/xmlreader/php_xmlreader.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,12 @@ static int xmlreader_property_reader(xmlreader_object *obj, xmlreader_prop_handl
113113
zval *xmlreader_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot)
114114
{
115115
zval *retval = NULL;
116-
xmlreader_prop_handler *hnd = zend_hash_find_ptr(&xmlreader_prop_handlers, name);
117116

117+
xmlreader_prop_handler *hnd = zend_hash_find_ptr(&xmlreader_prop_handlers, name);
118118
if (hnd == NULL) {
119119
retval = zend_std_get_property_ptr_ptr(object, name, type, cache_slot);
120+
} else {
121+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
120122
}
121123

122124
return retval;

‎ext/zip/php_zip.c

+2
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,8 @@ static zval *php_zip_get_property_ptr_ptr(zend_object *object, zend_string *name
889889
zval *retval = NULL;
890890
zip_prop_handler *hnd = NULL;
891891

892+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
893+
892894
obj = php_zip_fetch_object(object);
893895

894896
if (obj->prop_handler != NULL) {

0 commit comments

Comments
 (0)