Skip to content

Commit aca474f

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Fixed #67985 - Incorrect last used array index copied to new array after unset
2 parents bdac08b + 99f0760 commit aca474f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Zend/tests/bug67985.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #67985 - Last used array index not copied to new array at assignment
3+
--FILE--
4+
<?php
5+
6+
$a = ['zero', 'one', 'two'];
7+
unset($a[2]);
8+
$b = $a;
9+
$a[] = 'three';
10+
$b[] = 'three';
11+
12+
var_dump($a === $b);
13+
14+
?>
15+
--EXPECT--
16+
bool(true)

Zend/zend_variables.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
136136
ALLOC_HASHTABLE_REL(tmp_ht);
137137
zend_hash_init(tmp_ht, zend_hash_num_elements(original_ht), NULL, ZVAL_PTR_DTOR, 0);
138138
zend_hash_copy(tmp_ht, original_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
139+
tmp_ht->nNextFreeElement = original_ht->nNextFreeElement;
139140
zvalue->value.ht = tmp_ht;
140141
}
141142
break;

0 commit comments

Comments
 (0)