Skip to content

Commit 5733fd1

Browse files
bp1222nikic
authored andcommitted
Fix #73753 - Unpacked Arrays and Duplication
1 parent becda86 commit 5733fd1

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PHP NEWS
88
with list()). (Laruence)
99
. Fixed bug #73585 (Logging of "Internal Zend error - Missing class
1010
information" missing class name). (Laruence)
11+
. Fixed bug #73753 (unserialized array pointer not advancing). (David Walker)
1112

1213
- COM:
1314
. Fixed bug #73679 (DOTNET read access violation using invalid codepage).

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
@@ -1757,7 +1757,7 @@ static zend_always_inline void zend_array_dup_packed_elements(HashTable *source,
17571757

17581758
static zend_always_inline uint32_t zend_array_dup_elements(HashTable *source, HashTable *target, int static_keys, int with_holes)
17591759
{
1760-
uint32_t idx = 0;
1760+
uint32_t idx = 0;
17611761
Bucket *p = source->arData;
17621762
Bucket *q = target->arData;
17631763
Bucket *end = p + source->nNumUsed;
@@ -1785,7 +1785,7 @@ static zend_always_inline uint32_t zend_array_dup_elements(HashTable *source, Ha
17851785

17861786
ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
17871787
{
1788-
uint32_t idx;
1788+
uint32_t idx;
17891789
HashTable *target;
17901790

17911791
IS_CONSISTENT(source);
@@ -1849,7 +1849,8 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
18491849
target->u.flags = (source->u.flags & ~(HASH_FLAG_PERSISTENT|ZEND_HASH_APPLY_COUNT_MASK)) | HASH_FLAG_APPLY_PROTECTION;
18501850
target->nTableMask = source->nTableMask;
18511851
target->nNextFreeElement = source->nNextFreeElement;
1852-
target->nInternalPointer = HT_INVALID_IDX;
1852+
target->nInternalPointer = source->nInternalPointer;
1853+
18531854
HT_SET_DATA_ADDR(target, emalloc(HT_SIZE(target)));
18541855
HT_HASH_RESET(target);
18551856

0 commit comments

Comments
 (0)