summaryrefslogtreecommitdiff
path: root/ext/simplexml
diff options
context:
space:
mode:
authorFelipe Pena <felipensp@gmail.com>2014-05-10 11:39:08 -0300
committerFelipe Pena <felipensp@gmail.com>2014-05-10 11:39:08 -0300
commit5bd443a4520a542cd3f86f9d549eca78f693f730 (patch)
tree06d23bd1095989547575bc96eb885e925c5dfbf9 /ext/simplexml
parent4392339c3ec9dab6be0edf9f4373654993de6fa4 (diff)
downloadphp-git-5bd443a4520a542cd3f86f9d549eca78f693f730.tar.gz
- Fixed missing NULL check
Diffstat (limited to 'ext/simplexml')
-rw-r--r--ext/simplexml/simplexml.c9
-rw-r--r--ext/simplexml/tests/SimpleXMLElement_getDocNamespaces.phpt9
2 files changed, 15 insertions, 3 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 15a8512a43..006d6c9491 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -1533,15 +1533,18 @@ SXE_METHOD(getDocNamespaces)
return;
}
- array_init(return_value);
-
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
if(from_root){
node = xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr);
}else{
GET_NODE(sxe, node);
}
-
+
+ if (node == NULL) {
+ RETURN_FALSE;
+ }
+
+ array_init(return_value);
sxe_add_registered_namespaces(sxe, node, recursive, return_value TSRMLS_CC);
}
/* }}} */
diff --git a/ext/simplexml/tests/SimpleXMLElement_getDocNamespaces.phpt b/ext/simplexml/tests/SimpleXMLElement_getDocNamespaces.phpt
new file mode 100644
index 0000000000..9df7591003
--- /dev/null
+++ b/ext/simplexml/tests/SimpleXMLElement_getDocNamespaces.phpt
@@ -0,0 +1,9 @@
+--TEST--
+Testing getDocNamespaces() with invalid XML
+--FILE--
+<?php
+$xml = @new SimpleXMLElement("X",1);
+var_dump($xml->getDocNamespaces());
+?>
+--EXPECTF--
+bool(false)