bug38347.phpt 555 B

12345678910111213141516171819202122232425262728
  1. --TEST--
  2. Bug #38347 (Segmentation fault when using foreach with an unknown/empty SimpleXMLElement)
  3. --EXTENSIONS--
  4. simplexml
  5. --FILE--
  6. <?php
  7. function iterate($xml)
  8. {
  9. print_r($xml);
  10. foreach ($xml->item as $item) {
  11. echo "This code will crash!";
  12. }
  13. }
  14. $xmlstr = "<xml><item>Item 1</item><item>Item 2</item></xml>";
  15. $xml = simplexml_load_string($xmlstr);
  16. iterate($xml->unknown);
  17. echo "Done\n";
  18. ?>
  19. --EXPECTF--
  20. SimpleXMLElement Object
  21. (
  22. )
  23. Warning: foreach() argument must be of type array|object, null given in %sbug38347.php on line 6
  24. Done