summaryrefslogtreecommitdiff
path: root/ext/simplexml
diff options
context:
space:
mode:
authorFelipe Pena <felipensp@gmail.com>2014-05-10 11:39:47 -0300
committerFelipe Pena <felipensp@gmail.com>2014-05-10 11:39:47 -0300
commitedbd6c7cc0921c57cee7368e5fc7c7f30a9c68f5 (patch)
treea072bcf5a3740ff9a179048440ae1681aae73345 /ext/simplexml
parent398ff21923f0efd1df72c817e1ec33227c90cc3a (diff)
parent2379ec474eb70ea73c86d03ca3722e7b33bee08e (diff)
downloadphp-git-edbd6c7cc0921c57cee7368e5fc7c7f30a9c68f5.tar.gz
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: - 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 f84e1e014d..d9a37d35ac 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)