Skip to content

Commit 3488540

Browse files
committed
Fixed bug #78409
This removes an incorrect optimization (I think this code used to be necessary to properly handle references in the Serializable based implementation, but now this code just avoids an array duplication in a way that is not sound).
1 parent 65ea6bb commit 3488540

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ PHP NEWS
2121
. Fixed bug #78410 (Cannot "manually" unserialize class that is final and
2222
extends an internal one). (Nikita)
2323

24+
- SPL:
25+
. Fixed bug #78409 (Segfault when creating instance of ArrayIterator without
26+
constructor). (Nikita)
27+
2428
08 Aug 2019, PHP 7.4.0beta2
2529

2630
- Core:

ext/spl/spl_array.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,11 +1875,6 @@ SPL_METHOD(Array, __unserialize)
18751875
if (flags & SPL_ARRAY_IS_SELF) {
18761876
zval_ptr_dtor(&intern->array);
18771877
ZVAL_UNDEF(&intern->array);
1878-
} else if (Z_TYPE_P(storage_zv) == IS_ARRAY) {
1879-
zval_ptr_dtor(&intern->array);
1880-
ZVAL_COPY_VALUE(&intern->array, storage_zv);
1881-
ZVAL_NULL(storage_zv);
1882-
SEPARATE_ARRAY(&intern->array);
18831878
} else {
18841879
spl_array_set_array(ZEND_THIS, intern, storage_zv, 0L, 1);
18851880
}

ext/spl/tests/bug78409.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #78409: Segfault when creating instance of ArrayIterator without constructor
3+
--FILE--
4+
<?php
5+
6+
$a = new ArrayObject;
7+
$u = [
8+
0,
9+
[],
10+
[],
11+
];
12+
$a->__unserialize($u);
13+
var_dump($u);
14+
15+
?>
16+
--EXPECT--
17+
array(3) {
18+
[0]=>
19+
int(0)
20+
[1]=>
21+
array(0) {
22+
}
23+
[2]=>
24+
array(0) {
25+
}
26+
}

0 commit comments

Comments
 (0)