mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Fix negative indices on empty array not affecting next chosen index
Changed the value of nNextFreeElement in _zend_empty_array from 0 to ZEND_LONG_MIN. Fixes GH-11154 Closes GH-11157
This commit is contained in:
parent
f127e6581a
commit
e2f477c2cb
2
NEWS
2
NEWS
@ -31,6 +31,8 @@ PHP NEWS
|
|||||||
values). (dstogov, nielsdos, ilutov)
|
values). (dstogov, nielsdos, ilutov)
|
||||||
. Fix bug GH-10935 (Use of trait doesn't redeclare static property if class
|
. Fix bug GH-10935 (Use of trait doesn't redeclare static property if class
|
||||||
has inherited it from its parent). (ilutov)
|
has inherited it from its parent). (ilutov)
|
||||||
|
. Fix bug GH-11154 (Negative indices on empty array don't affect next chosen
|
||||||
|
index). (ColinHDev)
|
||||||
|
|
||||||
- Date:
|
- Date:
|
||||||
. Implement More Appropriate Date/Time Exceptions RFC. (Derick)
|
. Implement More Appropriate Date/Time Exceptions RFC. (Derick)
|
||||||
|
@ -39,6 +39,8 @@ PHP 8.3 UPGRADE NOTES
|
|||||||
inherited from the parent class. This will create a separate static property
|
inherited from the parent class. This will create a separate static property
|
||||||
storage for the current class. This is analogous to adding the static
|
storage for the current class. This is analogous to adding the static
|
||||||
property to the class directly without traits.
|
property to the class directly without traits.
|
||||||
|
. Assigning a negative index n to an empty array will now make sure that the
|
||||||
|
next index is n+1 instead of 0.
|
||||||
|
|
||||||
- FFI:
|
- FFI:
|
||||||
. C functions that have a return type of void now return null instead of
|
. C functions that have a return type of void now return null instead of
|
||||||
|
@ -255,7 +255,7 @@ ZEND_API const HashTable zend_empty_array = {
|
|||||||
.nNumOfElements = 0,
|
.nNumOfElements = 0,
|
||||||
.nTableSize = HT_MIN_SIZE,
|
.nTableSize = HT_MIN_SIZE,
|
||||||
.nInternalPointer = 0,
|
.nInternalPointer = 0,
|
||||||
.nNextFreeElement = 0,
|
.nNextFreeElement = ZEND_LONG_MIN,
|
||||||
.pDestructor = ZVAL_PTR_DTOR
|
.pDestructor = ZVAL_PTR_DTOR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
18
ext/standard/tests/array/negative_index_empty_array.phpt
Normal file
18
ext/standard/tests/array/negative_index_empty_array.phpt
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
--TEST--
|
||||||
|
Test empty arrays with first added index being negative
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$a = [];
|
||||||
|
$a[-5] = "-5";
|
||||||
|
$a[] = "after -5";
|
||||||
|
|
||||||
|
var_dump($a);
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
array(2) {
|
||||||
|
[-5]=>
|
||||||
|
string(2) "-5"
|
||||||
|
[-4]=>
|
||||||
|
string(8) "after -5"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user