diff --git a/NEWS b/NEWS index c3df7be79eb..0a268eb4995 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 95ab191b778..14be941cd33 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -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`. diff --git a/ext/spl/tests/gh13531.phpt b/ext/spl/tests/gh13531.phpt new file mode 100644 index 00000000000..46503ccf22a --- /dev/null +++ b/ext/spl/tests/gh13531.phpt @@ -0,0 +1,28 @@ +--TEST-- +GH-13531 (Unable to resize SplfixedArray after being unserialized in PHP 8.2.15) +--FILE-- +setSize(6); +var_dump($unserialized); + +?> +--EXPECT-- +object(SplFixedArray)#2 (6) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + [4]=> + int(1) + [5]=> + NULL +}