diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | Zend/tests/bug73753.phpt | 29 | ||||
-rw-r--r-- | Zend/zend_hash.c | 7 |
3 files changed, 34 insertions, 3 deletions
@@ -8,6 +8,7 @@ PHP NEWS with list()). (Laruence) . Fixed bug #73585 (Logging of "Internal Zend error - Missing class information" missing class name). (Laruence) + . Fixed bug #73753 (unserialized array pointer not advancing). (David Walker) - COM: . Fixed bug #73679 (DOTNET read access violation using invalid codepage). diff --git a/Zend/tests/bug73753.phpt b/Zend/tests/bug73753.phpt new file mode 100644 index 0000000000..9a77f62f56 --- /dev/null +++ b/Zend/tests/bug73753.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #73753 Non packed arrays and duplication +--FILE-- +<?php +function iterate($current, $a, $result = null) { + if (!$current) { + return $result; + } + + return iterate(getNext($a), $a, $current); +} + +function getNext(&$a) { + return next($a); +} + +function getCurrent($a) { + return current($a); +} + +function traverse($a) { + return iterate(getCurrent($a), $a); +} + +$arr = array(1 => 'foo', 'b' => 'bar', 'baz'); +var_dump(traverse($arr)); +?> +--EXPECTF-- +string(3) "baz" diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index aecdac6379..322422da15 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -1757,7 +1757,7 @@ static zend_always_inline void zend_array_dup_packed_elements(HashTable *source, static zend_always_inline uint32_t zend_array_dup_elements(HashTable *source, HashTable *target, int static_keys, int with_holes) { - uint32_t idx = 0; + uint32_t idx = 0; Bucket *p = source->arData; Bucket *q = target->arData; Bucket *end = p + source->nNumUsed; @@ -1785,7 +1785,7 @@ static zend_always_inline uint32_t zend_array_dup_elements(HashTable *source, Ha ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source) { - uint32_t idx; + uint32_t idx; HashTable *target; IS_CONSISTENT(source); @@ -1849,7 +1849,8 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source) target->u.flags = (source->u.flags & ~(HASH_FLAG_PERSISTENT|ZEND_HASH_APPLY_COUNT_MASK)) | HASH_FLAG_APPLY_PROTECTION; target->nTableMask = source->nTableMask; target->nNextFreeElement = source->nNextFreeElement; - target->nInternalPointer = HT_INVALID_IDX; + target->nInternalPointer = source->nInternalPointer; + HT_SET_DATA_ADDR(target, emalloc(HT_SIZE(target))); HT_HASH_RESET(target); |