diff options
Diffstat (limited to 'ext/simplexml/tests/bug38347.phpt')
| -rw-r--r-- | ext/simplexml/tests/bug38347.phpt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ext/simplexml/tests/bug38347.phpt b/ext/simplexml/tests/bug38347.phpt new file mode 100644 index 000000000..c25fccea2 --- /dev/null +++ b/ext/simplexml/tests/bug38347.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #38347 (Segmentation fault when using foreach with an unknown/empty SimpleXMLElement) +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +function iterate($xml) +{ + print_r($xml); + foreach ($xml->item as $item) { + echo "This code will crash!"; + } +} + +$xmlstr = "<xml><item>Item 1</item><item>Item 2</item></xml>"; +$xml = simplexml_load_string($xmlstr); +iterate($xml->unknown); + +echo "Done\n"; +?> +--EXPECTF-- +SimpleXMLElement Object +( +) + +Warning: iterate(): Node no longer exists in %s on line %d +Done |
