mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3'
* PHP-8.3: Fix GH-13531: Unable to resize SplfixedArray after being unserialized in PHP 8.2.15
This commit is contained in:
@@ -89,6 +89,7 @@ static void spl_fixedarray_default_ctor(spl_fixedarray *array)
|
||||
{
|
||||
array->size = 0;
|
||||
array->elements = NULL;
|
||||
array->cached_resize = -1;
|
||||
}
|
||||
|
||||
/* Initializes the range [from, to) to null. Does not dtor existing elements. */
|
||||
@@ -107,6 +108,7 @@ static void spl_fixedarray_init_non_empty_struct(spl_fixedarray *array, zend_lon
|
||||
array->size = 0; /* reset size in case ecalloc() fails */
|
||||
array->elements = size ? safe_emalloc(size, sizeof(zval), 0) : NULL;
|
||||
array->size = size;
|
||||
array->cached_resize = -1;
|
||||
}
|
||||
|
||||
static void spl_fixedarray_init(spl_fixedarray *array, zend_long size)
|
||||
@@ -117,7 +119,6 @@ static void spl_fixedarray_init(spl_fixedarray *array, zend_long size)
|
||||
} else {
|
||||
spl_fixedarray_default_ctor(array);
|
||||
}
|
||||
array->cached_resize = -1;
|
||||
}
|
||||
|
||||
/* Copies the range [begin, end) into the fixedarray, beginning at `offset`.
|
||||
|
||||
28
ext/spl/tests/gh13531.phpt
Normal file
28
ext/spl/tests/gh13531.phpt
Normal file
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
GH-13531 (Unable to resize SplfixedArray after being unserialized in PHP 8.2.15)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$array = new SplFixedArray(5);
|
||||
$array[4] = 1;
|
||||
$serialized = serialize($array);
|
||||
$unserialized = unserialize($serialized);
|
||||
$unserialized->setSize(6);
|
||||
var_dump($unserialized);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
object(SplFixedArray)#2 (6) {
|
||||
[0]=>
|
||||
NULL
|
||||
[1]=>
|
||||
NULL
|
||||
[2]=>
|
||||
NULL
|
||||
[3]=>
|
||||
NULL
|
||||
[4]=>
|
||||
int(1)
|
||||
[5]=>
|
||||
NULL
|
||||
}
|
||||
Reference in New Issue
Block a user