]> granicus.if.org Git - php/commitdiff
MFH: fix bug #46003 (isset on nonexisting node return unexpected results)
authorRob Richards <rrichards@php.net>
Wed, 10 Sep 2008 16:29:18 +0000 (16:29 +0000)
committerRob Richards <rrichards@php.net>
Wed, 10 Sep 2008 16:29:18 +0000 (16:29 +0000)
add test

ext/simplexml/simplexml.c
ext/simplexml/tests/bug46003.phpt [new file with mode: 0644]

index 6f40566f63bc07636f68aae11617fdcde403dd13..54a1d8f8aab285d90a10588b1f57d6f91cdec1a6 100644 (file)
@@ -800,7 +800,7 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend
                                while (node) {
                                        xmlNodePtr nnext;
                                        nnext = node->next;
-                                       if (!xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member))) {
+                                       if ((node->type == XML_ELEMENT_NODE) && !xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member))) {
                                                break;
                                        }
                                        node = nnext;
diff --git a/ext/simplexml/tests/bug46003.phpt b/ext/simplexml/tests/bug46003.phpt
new file mode 100644 (file)
index 0000000..a10b018
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Bug #46003 (isset on nonexisting nodes return unexpected results)
+--FILE--
+<?php
+$xml =<<<XML
+<r>
+  <p>Test</p>
+  <o d='h'>
+    <xx rr='info' />
+    <yy rr='data' />
+  </o>
+</r>
+XML;
+
+$x = simplexml_load_string($xml);
+
+var_dump(isset($x->p));
+var_dump(isset($x->p->o));
+var_dump(isset($x->o->yy));
+var_dump(isset($x->o->zz));
+var_dump(isset($x->o->text));
+var_dump(isset($x->o->xx));
+?>
+--EXPECTF--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
\ No newline at end of file