summaryrefslogtreecommitdiff
path: root/ext/simplexml/tests/bug40451.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/simplexml/tests/bug40451.phpt')
-rw-r--r--ext/simplexml/tests/bug40451.phpt22
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/simplexml/tests/bug40451.phpt b/ext/simplexml/tests/bug40451.phpt
new file mode 100644
index 000000000..1a499a731
--- /dev/null
+++ b/ext/simplexml/tests/bug40451.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #40451 (addAttribute() may crash when used with non-existent child node)
+--FILE--
+<?php
+
+$string = <<<XML
+<?xml version="1.0"?>
+ <Host enable="true">
+ <Name>host.server.com</Name>
+ </Host>
+XML;
+
+$xml = simplexml_load_string($string);
+
+$add = $xml->addChild('Host');
+$add->Host->addAttribute('enable', 'true');
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: SimpleXMLElement::addAttribute(): Unable to locate parent Element in %s on line %d
+Done