Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -2539,7 +2539,11 @@ static zval *php_sxe_iterator_current_data(zend_object_iterator *iter) /* {{{ */
{
php_sxe_iterator *iterator = (php_sxe_iterator *)iter;

return &iterator->sxe->iter.data;
zval *data = &iterator->sxe->iter.data;
if (Z_ISUNDEF_P(data)) {
return NULL;
}
return data;
}
/* }}} */

Expand Down
12 changes: 12 additions & 0 deletions ext/simplexml/tests/gh16808.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
GH-16808 (Segmentation fault in RecursiveIteratorIterator->current() with a xml element input)
--EXTENSIONS--
simplexml
--FILE--
<?php
$sxe = new SimpleXMLElement("<root />");
$test = new RecursiveIteratorIterator($sxe);
var_dump($test->current());
?>
--EXPECT--
NULL
Loading