Skip to content

Commit d95b9d6

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix phpGH-17736: Assertion failure zend_reference_destroy()
2 parents 3677871 + ee4a9a4 commit d95b9d6

File tree

10 files changed

+36
-1
lines changed

10 files changed

+36
-1
lines changed

Zend/zend_execute.c

+3
Original file line numberDiff line numberDiff line change
@@ -3426,6 +3426,9 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
34263426
return;
34273427
}
34283428
}
3429+
} else if (prop_op_type == IS_CONST) {
3430+
/* CE mismatch, make cache slot consistent */
3431+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
34293432
}
34303433

34313434
/* Pointer on property callback is required */

ext/date/php_date.c

+1
Original file line numberDiff line numberDiff line change
@@ -4576,6 +4576,7 @@ static zval *date_interval_get_property_ptr_ptr(zend_object *object, zend_string
45764576
zend_string_equals_literal(name, "days") ||
45774577
zend_string_equals_literal(name, "invert") ) {
45784578
/* Fallback to read_property. */
4579+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
45794580
ret = NULL;
45804581
} else {
45814582
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
@@ -357,6 +357,7 @@ static zval *dom_get_property_ptr_ptr(zend_object *object, zend_string *name, in
357357
return zend_std_get_property_ptr_ptr(object, name, type, cache_slot);
358358
}
359359

360+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
360361
return NULL;
361362
}
362363

ext/pdo/pdo_stmt.c

+1
Original file line numberDiff line numberDiff line change
@@ -2388,6 +2388,7 @@ static zval *pdo_row_get_property_ptr_ptr(zend_object *object, zend_string *name
23882388
ZEND_IGNORE_VALUE(type);
23892389
ZEND_IGNORE_VALUE(cache_slot);
23902390

2391+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
23912392
return NULL;
23922393
}
23932394

ext/simplexml/simplexml.c

+2
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,8 @@ static zval *sxe_property_get_adr(zend_object *object, zend_string *zname, int f
631631
SXE_ITER type;
632632
zval member;
633633

634+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
635+
634636
sxe = php_sxe_fetch_object(object);
635637
GET_NODE(sxe, node);
636638
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
@@ -1921,6 +1921,7 @@ static zval *php_snmp_get_property_ptr_ptr(zend_object *object, zend_string *nam
19211921
return zend_std_get_property_ptr_ptr(object, name, type, cache_slot);
19221922
}
19231923

1924+
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
19241925
return NULL;
19251926
}
19261927

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
static 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)