]> granicus.if.org Git - php/commitdiff
fix regression introduced in 5683b6fa39
authorAnatol Belski <ab@php.net>
Tue, 8 Mar 2016 11:59:59 +0000 (12:59 +0100)
committerAnatol Belski <ab@php.net>
Tue, 8 Mar 2016 11:59:59 +0000 (12:59 +0100)
Test extended. Basically, both iterator type and next node have
to be checked.

ext/simplexml/simplexml.c
ext/simplexml/tests/bug66084_1.phpt

index af266348a39eb99eeabb77c7f34cf28d640f2f1f..07fc6546e896094aed794aea4691f0151774d955 100644 (file)
@@ -1129,7 +1129,7 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{
                        node = NULL;
                } else if (sxe->iter.type != SXE_ITER_CHILD) {
 
-                       if ( sxe->iter.type == SXE_ITER_NONE || !node->children || !node->parent || node->children->next || node->children->children || node->parent->children == node->parent->last ) {
+                       if ( sxe->iter.type == SXE_ITER_NONE || !node->children || !node->parent || !node->next || node->children->next || node->children->children || node->parent->children == node->parent->last ) {
                                node = node->children;
                        } else {
                                iter_data = sxe->iter.data;
index 80e91df7c6a36fce3b1870515e452fbd25479d89..85ab10ee59d080ba690f98d459c687480d9259fd 100644 (file)
@@ -5,12 +5,14 @@ Bug #66084 simplexml_load_string() mangles empty node name, json variant
 <?php if (!extension_loaded("json")) print "skip json not available"; ?>
 --FILE--
 <?php
+echo json_encode(simplexml_load_string('<a><b/><c><x/></c></a>')->c), "\n";
 echo json_encode(simplexml_load_string('<a><b/><c><x/></c></a>')), "\n";
 echo json_encode(simplexml_load_string('<a><b/><d/><c><x/></c></a>')), "\n";
 echo json_encode(simplexml_load_string('<a><b/><c><d/><x/></c></a>')), "\n";
 echo json_encode(simplexml_load_string('<a><b/><c><d><x/></d></c></a>')), "\n";
 ?>
 --EXPECT--
+{"x":{}}
 {"b":{},"c":{"x":{}}}
 {"b":{},"d":{},"c":{"x":{}}}
 {"b":{},"c":{"d":{},"x":{}}}