From: Rob Richards Date: Mon, 31 Oct 2005 19:51:40 +0000 (+0000) Subject: check node type before accessing ns - prevent corruption under compact mode X-Git-Tag: RELEASE_2_0_1~96 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c982bb62c2e82ea5059e169a181923be3364147;p=php check node type before accessing ns - prevent corruption under compact mode --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index b6783cc884..88a342fc0e 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1119,7 +1119,9 @@ static void sxe_add_namespaces(php_sxe_object *sxe, xmlNodePtr node, zend_bool r if (recursive) { node = node->children; while (node) { - sxe_add_namespaces(sxe, node, recursive, return_value TSRMLS_CC); + if (node->type == XML_ELEMENT_NODE) { + sxe_add_namespaces(sxe, node, recursive, return_value TSRMLS_CC); + } node = node->next; } } @@ -1147,7 +1149,7 @@ SXE_METHOD(getNamespaces) SKIP_TEXT(node) if (node->type == XML_ELEMENT_NODE) { sxe_add_namespaces(sxe, node, recursive, return_value TSRMLS_CC); - } else if (node->ns) { + } else if (node->type == XML_ATTRIBUTE_NODE && node->ns) { add_assoc_string(return_value, (char*)node->ns->prefix, (char*)node->ns->href, 1); } next_iter: