mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Merge branch 'PHP-8.3'
* PHP-8.3: Fix GH-12208: SimpleXML infinite loop when a cast is used inside a foreach
This commit is contained in:
@@ -1806,7 +1806,7 @@ static zend_result sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int
|
||||
sxe = php_sxe_fetch_object(readobj);
|
||||
|
||||
if (type == _IS_BOOL) {
|
||||
node = php_sxe_get_first_node(sxe, NULL);
|
||||
node = php_sxe_get_first_node_non_destructive(sxe, NULL);
|
||||
if (node) {
|
||||
ZVAL_TRUE(writeobj);
|
||||
} else {
|
||||
@@ -1816,7 +1816,7 @@ static zend_result sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int
|
||||
}
|
||||
|
||||
if (sxe->iter.type != SXE_ITER_NONE) {
|
||||
node = php_sxe_get_first_node(sxe, NULL);
|
||||
node = php_sxe_get_first_node_non_destructive(sxe, NULL);
|
||||
if (node) {
|
||||
contents = xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, node->children, 1);
|
||||
}
|
||||
|
||||
26
ext/simplexml/tests/gh12208.phpt
Normal file
26
ext/simplexml/tests/gh12208.phpt
Normal file
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
GH-12208 (SimpleXML infinite loop when a cast is used inside a foreach)
|
||||
--EXTENSIONS--
|
||||
simplexml
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$xml = "<root><a>1</a><a>2</a></root>";
|
||||
$xml = simplexml_load_string($xml);
|
||||
|
||||
$a = $xml->a;
|
||||
|
||||
foreach ($a as $test) {
|
||||
var_dump((string) $a->current());
|
||||
var_dump((string) $a);
|
||||
var_dump((bool) $a);
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(1) "1"
|
||||
string(1) "1"
|
||||
bool(true)
|
||||
string(1) "2"
|
||||
string(1) "1"
|
||||
bool(true)
|
||||
Reference in New Issue
Block a user