diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2017-12-22 18:00:17 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-12-22 18:01:03 +0100 |
commit | ccb113c3e5964ef2d2e5b4ae3e67d61702db9bfc (patch) | |
tree | ab7b6c57fe8126cbc502d430fcd33d418e16bc3f /ext | |
parent | 024637378827ff03ccfb6b903c9d9b968d30af8d (diff) | |
download | php-git-ccb113c3e5964ef2d2e5b4ae3e67d61702db9bfc.tar.gz |
Fixed bug #75717
Diffstat (limited to 'ext')
-rw-r--r-- | ext/spl/spl_array.c | 1 | ||||
-rw-r--r-- | ext/spl/tests/bug75717.phpt | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 81bbe48bd4..1be55d785b 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1642,6 +1642,7 @@ SPL_METHOD(Array, hasChildren) RETURN_FALSE; } + ZVAL_DEREF(entry); RETURN_BOOL(Z_TYPE_P(entry) == IS_ARRAY || (Z_TYPE_P(entry) == IS_OBJECT && (intern->ar_flags & SPL_ARRAY_CHILD_ARRAYS_ONLY) == 0)); } /* }}} */ diff --git a/ext/spl/tests/bug75717.phpt b/ext/spl/tests/bug75717.phpt new file mode 100644 index 0000000000..485b9d8bc4 --- /dev/null +++ b/ext/spl/tests/bug75717.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #75717: RecursiveArrayIterator does not traverse arrays by reference +--FILE-- +<?php + +function flatten(array $nestedArraysAndStrings){ + $flat=[]; + $iter = new RecursiveIteratorIterator( + new RecursiveArrayIterator($nestedArraysAndStrings)); + foreach($iter as $leaf){ $flat[] = $leaf; } + return join(NULL, $flat); +} + +$noRefs = [[[['some']]],[' nested '],"items"]; + +$withRefs = []+$noRefs; +$wat = $noRefs[0]; +$withRefs[0] = &$wat; + +echo flatten($noRefs), "\n"; +echo flatten($withRefs), "\n"; + +?> +--EXPECT-- +some nested items +some nested items |