]> granicus.if.org Git - php/commitdiff
- Fixed missing NULL check in SimpleXMLElement::xpath()
authorFelipe Pena <felipensp@gmail.com>
Sat, 10 May 2014 14:53:40 +0000 (11:53 -0300)
committerFelipe Pena <felipensp@gmail.com>
Sat, 10 May 2014 14:53:40 +0000 (11:53 -0300)
ext/simplexml/simplexml.c
ext/simplexml/tests/SimpleXMLElement_xpath.phpt [new file with mode: 0644]

index 006d6c9491608602c6d0afd0b748b869a63967b1..0f05f52c1cb14aad61ce1867a5751dc8b6649ca5 100644 (file)
@@ -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 (file)
index 0000000..4a613c2
--- /dev/null
@@ -0,0 +1,8 @@
+--TEST--
+Testing xpath() with invalid XML
+--FILE--
+<?php
+$xml = @simplexml_load_string("XXXXXXX^",$x,0x6000000000000001);
+var_dump($xml->xpath("BBBB"));
+--EXPECT--
+bool(false)