Fix #73753 - Unpacked Arrays and Duplication

This commit is contained in:
David Walker 2016-12-20 15:48:43 -07:00 committed by Nikita Popov
parent becda86ae5
commit 5733fd1caf
3 changed files with 34 additions and 3 deletions

1
NEWS
View File

@ -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).

29
Zend/tests/bug73753.phpt Normal file
View File

@ -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"

View File

@ -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);