Skip to content
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

Fix getting the address of an uninitialized property of a SimpleXMLElement resulting in a crash #12945

Closed
wants to merge 1 commit 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 ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@ static zval *sxe_property_get_adr(zend_object *object, zend_string *zname, int f

sxe = php_sxe_fetch_object(object);
GET_NODE(sxe, node);
if (UNEXPECTED(!node)) {
return &EG(error_zval);
}
name = ZSTR_VAL(zname);
node = sxe_get_element_by_name(sxe, node, &name, &type);
if (node) {
Expand Down
17 changes: 17 additions & 0 deletions ext/simplexml/tests/get_prop_address_not_initialized.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Getting the address of an uninitialized property of a SimpleXMLElement
--EXTENSIONS--
simplexml
--FILE--
<?php

$rc = new ReflectionClass('SimpleXMLElement');
$sxe = $rc->newInstanceWithoutConstructor();
$sxe->a['b'] = 'b';

?>
--EXPECTF--
Fatal error: Uncaught Error: SimpleXMLElement is not properly initialized in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d