From: Felipe Pena Date: Sat, 10 May 2014 14:53:40 +0000 (-0300) Subject: - Fixed missing NULL check in SimpleXMLElement::xpath() X-Git-Tag: php-5.4.29RC1~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=345f6d90d5947c5cf380db79c1c6366a72cc6e8d;p=php - Fixed missing NULL check in SimpleXMLElement::xpath() --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 006d6c9491..0f05f52c1c 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1270,6 +1270,9 @@ SXE_METHOD(xpath) if (!sxe->node) { php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement((xmlDocPtr) sxe->document->ptr), NULL TSRMLS_CC); } + if (!sxe->node) { + RETURN_FALSE; + } nodeptr = php_sxe_get_first_node(sxe, sxe->node->node TSRMLS_CC); diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath.phpt b/ext/simplexml/tests/SimpleXMLElement_xpath.phpt new file mode 100644 index 0000000000..4a613c2e51 --- /dev/null +++ b/ext/simplexml/tests/SimpleXMLElement_xpath.phpt @@ -0,0 +1,8 @@ +--TEST-- +Testing xpath() with invalid XML +--FILE-- +xpath("BBBB")); +--EXPECT-- +bool(false)