Skip to content

Commit 2ba1859

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix phpGH-16808: Segmentation fault in RecursiveIteratorIterator->current() with a xml element input
2 parents 179ca2b + fbb0061 commit 2ba1859

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ PHP NEWS
4040
. Fixed bug GH-16695 (phar:// tar parser and zero-length file header blocks).
4141
(nielsdos, Hans Krentel)
4242

43+
- SimpleXML:
44+
. Fixed bug GH-16808 (Segmentation fault in RecursiveIteratorIterator
45+
->current() with a xml element input). (nielsdos)
46+
4347
- SOAP:
4448
. Fix make check being invoked in ext/soap. (Ma27)
4549

ext/simplexml/simplexml.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2532,7 +2532,11 @@ static zval *php_sxe_iterator_current_data(zend_object_iterator *iter) /* {{{ */
25322532
{
25332533
php_sxe_iterator *iterator = (php_sxe_iterator *)iter;
25342534

2535-
return &iterator->sxe->iter.data;
2535+
zval *data = &iterator->sxe->iter.data;
2536+
if (Z_ISUNDEF_P(data)) {
2537+
return NULL;
2538+
}
2539+
return data;
25362540
}
25372541
/* }}} */
25382542

ext/simplexml/tests/gh16808.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-16808 (Segmentation fault in RecursiveIteratorIterator->current() with a xml element input)
3+
--EXTENSIONS--
4+
simplexml
5+
--FILE--
6+
<?php
7+
$sxe = new SimpleXMLElement("<root />");
8+
$test = new RecursiveIteratorIterator($sxe);
9+
var_dump($test->current());
10+
?>
11+
--EXPECT--
12+
NULL

0 commit comments

Comments
 (0)