Skip to content

Commit 0285395

Browse files
committed
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
2 parents 4dc8c08 + 8494058 commit 0285395

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ PHP NEWS
3939
. Fixed bug GH-13519 (PGSQL_CONNECT_FORCE_RENEW not working with persistent
4040
connections. (David Carlier)
4141

42+
- SPL:
43+
. Fixed bug GH-13531 (Unable to resize SplfixedArray after being unserialized
44+
in PHP 8.2.15). (nielsdos)
45+
4246
- Standard:
4347
. Fixed bug GH-13279 (Instable array during in-place modification in uksort).
4448
(ilutov)

ext/spl/spl_fixedarray.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static void spl_fixedarray_default_ctor(spl_fixedarray *array)
8989
{
9090
array->size = 0;
9191
array->elements = NULL;
92+
array->cached_resize = -1;
9293
}
9394

9495
/* 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
107108
array->size = 0; /* reset size in case ecalloc() fails */
108109
array->elements = size ? safe_emalloc(size, sizeof(zval), 0) : NULL;
109110
array->size = size;
111+
array->cached_resize = -1;
110112
}
111113

112114
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)
117119
} else {
118120
spl_fixedarray_default_ctor(array);
119121
}
120-
array->cached_resize = -1;
121122
}
122123

123124
/* Copies the range [begin, end) into the fixedarray, beginning at `offset`.

ext/spl/tests/gh13531.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
GH-13531 (Unable to resize SplfixedArray after being unserialized in PHP 8.2.15)
3+
--FILE--
4+
<?php
5+
6+
$array = new SplFixedArray(5);
7+
$array[4] = 1;
8+
$serialized = serialize($array);
9+
$unserialized = unserialize($serialized);
10+
$unserialized->setSize(6);
11+
var_dump($unserialized);
12+
13+
?>
14+
--EXPECT--
15+
object(SplFixedArray)#2 (6) {
16+
[0]=>
17+
NULL
18+
[1]=>
19+
NULL
20+
[2]=>
21+
NULL
22+
[3]=>
23+
NULL
24+
[4]=>
25+
int(1)
26+
[5]=>
27+
NULL
28+
}

0 commit comments

Comments
 (0)