Skip to content

Commit 81c2a4b

Browse files
jhdxrkrakjoe
authored andcommitted
fix bug #73471 PHP freezes with AppendIterator
1 parent db287b2 commit 81c2a4b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ PHP NEWS
66
. Fixed bug #74780 (parse_url() borken when query string contains colon).
77
(jhdxr)
88

9+
- SPL:
10+
. Fixed bug #73471 (PHP freezes with AppendIterator). (jhdxr)
11+
912
06 Jul 2017 PHP 7.0.21
1013

1114
- Core:

ext/spl/spl_iterators.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3383,7 +3383,12 @@ SPL_METHOD(AppendIterator, append)
33833383
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "O", &it, zend_ce_iterator) == FAILURE) {
33843384
return;
33853385
}
3386-
spl_array_iterator_append(&intern->u.append.zarrayit, it);
3386+
if (intern->u.append.iterator->funcs->valid(intern->u.append.iterator) == SUCCESS) {
3387+
spl_array_iterator_append(&intern->u.append.zarrayit, it);
3388+
intern->u.append.iterator->funcs->move_forward(intern->u.append.iterator);
3389+
}else{
3390+
spl_array_iterator_append(&intern->u.append.zarrayit, it);
3391+
}
33873392

33883393
if (!intern->inner.iterator || spl_dual_it_valid(intern) != SUCCESS) {
33893394
if (intern->u.append.iterator->funcs->valid(intern->u.append.iterator) != SUCCESS) {

ext/spl/tests/bug73471.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #73471 PHP freezes with AppendIterator
3+
--FILE--
4+
<?php
5+
6+
$iterator = new \AppendIterator();
7+
$events = new \ArrayIterator([1,2,3,4,5]);
8+
$events2 = new \ArrayIterator(['a', 'b', 'c']);
9+
$iterator->append($events);
10+
foreach($events as $event){}
11+
$iterator->append($events2);
12+
?>
13+
===DONE===
14+
--EXPECT--
15+
===DONE===

0 commit comments

Comments
 (0)