1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix GH-13531: Unable to resize SplfixedArray after being unserialized in PHP 8.2.15
This commit is contained in:
Niels Dossche
2024-02-27 23:05:26 +01:00
3 changed files with 34 additions and 1 deletions

4
NEWS
View File

@@ -39,6 +39,10 @@ PHP NEWS
. Fixed bug GH-13519 (PGSQL_CONNECT_FORCE_RENEW not working with persistent
connections. (David Carlier)
- SPL:
. Fixed bug GH-13531 (Unable to resize SplfixedArray after being unserialized
in PHP 8.2.15). (nielsdos)
- Standard:
. Fixed bug GH-13279 (Instable array during in-place modification in uksort).
(ilutov)

View File

@@ -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`.

View 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
}