com php-src: Fix #73753 - Unpacked Arrays and Duplication: NEWS Zend/tests/bug73753.phpt Zend/zend_hash.c
| From: | Nikita Popov | Date: | Wed, 21 Dec 2016 20:18:20 +0000 |
| Subject: | com php-src: Fix #73753 - Unpacked Arrays and Duplication: NEWS Zend/tests/bug73753.phpt Zend/zend_hash.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96406@lists.php.net to get a copy of this message | ||
Commit: 5733fd1cafe8d0e2306626c525ad081b7ee30d96
Author: David Walker <dave@mudsite.com> Tue, 20 Dec 2016 15:48:43 -0700
Committer: Nikita Popov <nikic@php.net> Wed, 21 Dec 2016 21:18:20 +0100
Parents: becda86ae5dbf7abb1afabd14e84113b2785a345
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5733fd1cafe8d0e2306626c525ad081b7ee30d96
Log:
Fix #73753 - Unpacked Arrays and Duplication
Bugs:
https://bugs.php.net/73753
Changed paths:
M NEWS
A Zend/tests/bug73753.phpt
M Zend/zend_hash.c
Diff:
diff --git a/NEWS b/NEWS
index 98b88cc..53186e7 100644
--- a/NEWS
+++ b/NEWS
@@ -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 0000000..9a77f62
--- /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 aecdac6..322422d 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);