Skip to content

Commit a1fd105

Browse files
committed
Merge branch 'PHP-7.1'
2 parents 509f26c + 9afc61c commit a1fd105

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

Zend/tests/bug73753.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #73753 Non packed arrays and duplication
3+
--FILE--
4+
<?php
5+
function iterate($current, $a, $result = null) {
6+
if (!$current) {
7+
return $result;
8+
}
9+
10+
return iterate(getNext($a), $a, $current);
11+
}
12+
13+
function getNext(&$a) {
14+
return next($a);
15+
}
16+
17+
function getCurrent($a) {
18+
return current($a);
19+
}
20+
21+
function traverse($a) {
22+
return iterate(getCurrent($a), $a);
23+
}
24+
25+
$arr = array(1 => 'foo', 'b' => 'bar', 'baz');
26+
var_dump(traverse($arr));
27+
?>
28+
--EXPECTF--
29+
string(3) "baz"

Zend/zend_hash.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ static zend_always_inline void zend_array_dup_packed_elements(HashTable *source,
17251725

17261726
static zend_always_inline uint32_t zend_array_dup_elements(HashTable *source, HashTable *target, int static_keys, int with_holes)
17271727
{
1728-
uint32_t idx = 0;
1728+
uint32_t idx = 0;
17291729
Bucket *p = source->arData;
17301730
Bucket *q = target->arData;
17311731
Bucket *end = p + source->nNumUsed;
@@ -1753,7 +1753,7 @@ static zend_always_inline uint32_t zend_array_dup_elements(HashTable *source, Ha
17531753

17541754
ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
17551755
{
1756-
uint32_t idx;
1756+
uint32_t idx;
17571757
HashTable *target;
17581758

17591759
IS_CONSISTENT(source);
@@ -1817,7 +1817,8 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
18171817
target->u.flags = (source->u.flags & ~(HASH_FLAG_PERSISTENT|ZEND_HASH_APPLY_COUNT_MASK)) | HASH_FLAG_APPLY_PROTECTION;
18181818
target->nTableMask = source->nTableMask;
18191819
target->nNextFreeElement = source->nNextFreeElement;
1820-
target->nInternalPointer = HT_INVALID_IDX;
1820+
target->nInternalPointer = source->nInternalPointer;
1821+
18211822
HT_SET_DATA_ADDR(target, emalloc(HT_SIZE(target)));
18221823
HT_HASH_RESET(target);
18231824

0 commit comments

Comments
 (0)