Skip to content

Commit bc20b40

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-15837: Segmentation fault in ext/simplexml/simplexml.c
2 parents b0bead4 + b5834c1 commit bc20b40

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

NEWS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.3.13
44

5-
- Opcache:
5+
- SimpleXML:
6+
. Fixed bug GH-15837 (Segmentation fault in ext/simplexml/simplexml.c).
7+
(nielsdos)
8+
9+
- SOAP:
610
. Fixed bug #73182 (PHP SOAPClient does not support stream context HTTP
711
headers in array form). (nielsdos)
812
. Fixed bug #62900 (Wrong namespace on xsd import error message). (nielsdos)

ext/simplexml/simplexml.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,6 +2540,11 @@ static void php_sxe_iterator_current_key(zend_object_iterator *iter, zval *key)
25402540
{
25412541
php_sxe_iterator *iterator = (php_sxe_iterator *)iter;
25422542
zval *curobj = &iterator->sxe->iter.data;
2543+
if (Z_ISUNDEF_P(curobj)) {
2544+
ZVAL_NULL(key);
2545+
return;
2546+
}
2547+
25432548
php_sxe_object *intern = Z_SXEOBJ_P(curobj);
25442549

25452550
xmlNodePtr curnode = NULL;

ext/simplexml/tests/gh15837.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
GH-15837 (Segmentation fault in ext/simplexml/simplexml.c)
3+
--CREDITS--
4+
YuanchengJiang
5+
--FILE--
6+
<?php
7+
$xml =<<<EOF
8+
<xml>
9+
<fieldset1>
10+
</fieldset1>
11+
<fieldset2>
12+
<options>
13+
</options>
14+
</fieldset2>
15+
</xml>
16+
EOF;
17+
$sxe = new SimpleXMLIterator($xml);
18+
$rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::LEAVES_ONLY);
19+
foreach ($rit as $child) {
20+
$ancestry = $child->xpath('ancestor-or-self::*');
21+
// Exhaust internal iterator
22+
foreach ($ancestry as $ancestor) {
23+
}
24+
}
25+
var_dump($rit->valid());
26+
var_dump($rit->key());
27+
?>
28+
--EXPECT--
29+
bool(false)
30+
NULL

0 commit comments

Comments
 (0)