diff options
| -rw-r--r-- | NEWS | 3 | ||||
| -rw-r--r-- | Zend/tests/bug79364.phpt | 22 | ||||
| -rw-r--r-- | Zend/zend_hash.c | 2 |
3 files changed, 26 insertions, 1 deletions
@@ -3,6 +3,9 @@ PHP NEWS ?? ??? ????, PHP 7.4.5 +- Core: + . Fixed bug #79364 (When copy empty array, next key is unspecified). (cmb) + - SOAP: . Fixed bug #79357 (SOAP request segfaults when any request parameter is missing). (Nikita) diff --git a/Zend/tests/bug79364.phpt b/Zend/tests/bug79364.phpt new file mode 100644 index 0000000000..6d96b4d793 --- /dev/null +++ b/Zend/tests/bug79364.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #79364 (When copy empty array, next key is unspecified) +--FILE-- +<?php +$a = [1, 2]; +unset($a[1], $a[0]); +$b = $a; + +$a[] = 3; +$b[] = 4; + +var_dump($a, $b); +?> +--EXPECT-- +array(1) { + [2]=> + int(3) +} +array(1) { + [2]=> + int(4) +} diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index c2c8cf825f..e342da889b 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -2055,7 +2055,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source) target->nTableMask = HT_MIN_MASK; target->nNumUsed = 0; target->nNumOfElements = 0; - target->nNextFreeElement = 0; + target->nNextFreeElement = source->nNextFreeElement; target->nInternalPointer = 0; target->nTableSize = HT_MIN_SIZE; HT_SET_DATA_ADDR(target, &uninitialized_bucket); |
