diff options
author | jhdxr <jhdxr@php.net> | 2017-09-11 02:11:58 +0800 |
---|---|---|
committer | Joe Watkins <krakjoe@php.net> | 2017-09-12 07:05:58 +0100 |
commit | 3e11b7fc217ee3ce7a3a2833a062d73537cf6bcc (patch) | |
tree | 1f6122a7404e69d4d78e6f17ae546802ad958dc9 /ext | |
parent | 9aa6898b9be78bb1e138488c3204bb745a31aca7 (diff) | |
download | php-git-3e11b7fc217ee3ce7a3a2833a062d73537cf6bcc.tar.gz |
fix bug #75173 incorrect behavior of AppendIterator::append in foreach loop
Diffstat (limited to 'ext')
-rw-r--r-- | ext/spl/spl_iterators.c | 2 | ||||
-rw-r--r-- | ext/spl/tests/bug75173.phpt | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index fafa9dc7b1..e32f1e894b 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -3384,7 +3384,7 @@ SPL_METHOD(AppendIterator, append) if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "O", &it, zend_ce_iterator) == FAILURE) { return; } - if (intern->u.append.iterator->funcs->valid(intern->u.append.iterator) == SUCCESS) { + if (intern->u.append.iterator->funcs->valid(intern->u.append.iterator) == SUCCESS && spl_dual_it_valid(intern) != SUCCESS) { spl_array_iterator_append(&intern->u.append.zarrayit, it); intern->u.append.iterator->funcs->move_forward(intern->u.append.iterator); }else{ diff --git a/ext/spl/tests/bug75173.phpt b/ext/spl/tests/bug75173.phpt new file mode 100644 index 0000000000..a2cc9097b1 --- /dev/null +++ b/ext/spl/tests/bug75173.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #75173 incorrect behavior of AppendIterator::append in foreach loop +--FILE-- +<?php + +$it = new \AppendIterator(); +$it->append(new ArrayIterator(['foo'])); + +foreach ($it as $item) { + var_dump($item); + + if ('foo' === $item) { + $it->append(new ArrayIterator(['bar'])); + } +} +--EXPECT-- +string(3) "foo" +string(3) "bar" |