Skip to content

Fix GH-17736: Assertion failure zend_reference_destroy() #17739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -3232,6 +3232,9 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
return;
}
}
} else if (prop_op_type == IS_CONST) {
/* CE mismatch, make cache slot consistent */
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
}

/* Pointer on property callback is required */
Expand Down
1 change: 1 addition & 0 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -4399,6 +4399,7 @@ static zval *date_interval_get_property_ptr_ptr(zend_object *object, zend_string
zend_string_equals_literal(name, "days") ||
zend_string_equals_literal(name, "invert") ) {
/* Fallback to read_property. */
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
ret = NULL;
} else {
ret = zend_std_get_property_ptr_ptr(object, name, type, cache_slot);
Expand Down
1 change: 1 addition & 0 deletions ext/dom/php_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ static zval *dom_get_property_ptr_ptr(zend_object *object, zend_string *name, in
return zend_std_get_property_ptr_ptr(object, name, type, cache_slot);
}

cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
return NULL;
}

Expand Down
1 change: 1 addition & 0 deletions ext/pdo/pdo_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2495,6 +2495,7 @@ static zval *pdo_row_get_property_ptr_ptr(zend_object *object, zend_string *name
ZEND_IGNORE_VALUE(type);
ZEND_IGNORE_VALUE(cache_slot);

cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
return NULL;
}

Expand Down
2 changes: 2 additions & 0 deletions ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,8 @@ static zval *sxe_property_get_adr(zend_object *object, zend_string *zname, int f
SXE_ITER type;
zval member;

cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;

sxe = php_sxe_fetch_object(object);
GET_NODE(sxe, node);
if (UNEXPECTED(!node)) {
Expand Down
20 changes: 20 additions & 0 deletions ext/simplexml/tests/gh17736.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
GH-17736 (Assertion failure zend_reference_destroy())
--EXTENSIONS--
simplexml
--FILE--
<?php
$o1 = new SimpleXMLElement('<a/>');
class C {
public int $a = 1;
}
function test($obj) {
$ref =& $obj->a;
}
$obj = new C;
test($obj);
test($o1);
echo "Done\n";
?>
--EXPECT--
Done
1 change: 1 addition & 0 deletions ext/snmp/snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,7 @@ static zval *php_snmp_get_property_ptr_ptr(zend_object *object, zend_string *nam
return zend_std_get_property_ptr_ptr(object, name, type, cache_slot);
}

cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;
return NULL;
}

Expand Down
2 changes: 2 additions & 0 deletions ext/spl/spl_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,8 @@ static zval *spl_array_get_property_ptr_ptr(zend_object *object, zend_string *na

if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
&& !zend_std_has_property(object, name, ZEND_PROPERTY_EXISTS, NULL)) {
cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;

/* If object has offsetGet() overridden, then fallback to read_property,
* which will call offsetGet(). */
zval member;
Expand Down
2 changes: 2 additions & 0 deletions ext/xmlreader/php_xmlreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ zval *xmlreader_get_property_ptr_ptr(zend_object *object, zend_string *name, int
zval *retval = NULL;
xmlreader_prop_handler *hnd = NULL;

cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;

obj = php_xmlreader_fetch_object(object);

if (obj->prop_handler != NULL) {
Expand Down
2 changes: 2 additions & 0 deletions ext/zip/php_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,8 @@ static zval *php_zip_get_property_ptr_ptr(zend_object *object, zend_string *name
zval *retval = NULL;
zip_prop_handler *hnd = NULL;

cache_slot[0] = cache_slot[1] = cache_slot[2] = NULL;

obj = php_zip_fetch_object(object);

if (obj->prop_handler != NULL) {
Expand Down
Loading