Annotation of embedaddon/php/ext/simplexml/tests/bug38347.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #38347 (Segmentation fault when using foreach with an unknown/empty SimpleXMLElement)
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("simplexml")) print "skip"; ?>
! 5: --FILE--
! 6: <?php
! 7:
! 8: function iterate($xml)
! 9: {
! 10: print_r($xml);
! 11: foreach ($xml->item as $item) {
! 12: echo "This code will crash!";
! 13: }
! 14: }
! 15:
! 16: $xmlstr = "<xml><item>Item 1</item><item>Item 2</item></xml>";
! 17: $xml = simplexml_load_string($xmlstr);
! 18: iterate($xml->unknown);
! 19:
! 20: echo "Done\n";
! 21: ?>
! 22: --EXPECTF--
! 23: SimpleXMLElement Object
! 24: (
! 25: )
! 26:
! 27: Warning: Invalid argument supplied for foreach() in %sbug38347.php on line 6
! 28: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>