Skip to content

Commit a72b261

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79364: When copy empty array, next key is unspecified
2 parents f73528f + 2462f2d commit a72b261

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ PHP NEWS
33

44
?? ??? ????, PHP 7.4.5
55

6+
- Core:
7+
. Fixed bug #79364 (When copy empty array, next key is unspecified). (cmb)
8+
69
- SOAP:
710
. Fixed bug #79357 (SOAP request segfaults when any request parameter is
811
missing). (Nikita)

Zend/tests/bug79364.phpt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #79364 (When copy empty array, next key is unspecified)
3+
--FILE--
4+
<?php
5+
$a = [1, 2];
6+
unset($a[1], $a[0]);
7+
$b = $a;
8+
9+
$a[] = 3;
10+
$b[] = 4;
11+
12+
var_dump($a, $b);
13+
?>
14+
--EXPECT--
15+
array(1) {
16+
[2]=>
17+
int(3)
18+
}
19+
array(1) {
20+
[2]=>
21+
int(4)
22+
}

Zend/zend_hash.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
20552055
target->nTableMask = HT_MIN_MASK;
20562056
target->nNumUsed = 0;
20572057
target->nNumOfElements = 0;
2058-
target->nNextFreeElement = 0;
2058+
target->nNextFreeElement = source->nNextFreeElement;
20592059
target->nInternalPointer = 0;
20602060
target->nTableSize = HT_MIN_SIZE;
20612061
HT_SET_DATA_ADDR(target, &uninitialized_bucket);

0 commit comments

Comments
 (0)