Skip to content

Commit e28cb9d

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 4c70a58 + 9483c50 commit e28cb9d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ext/spl/spl_dllist.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,7 @@ SPL_METHOD(SplDoublyLinkedList, __serialize)
12371237
array_init_size(&tmp, intern->llist->count);
12381238
while (current) {
12391239
zend_hash_next_index_insert(Z_ARRVAL(tmp), &current->data);
1240+
Z_TRY_ADDREF(current->data);
12401241
current = current->next;
12411242
}
12421243
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);

ext/spl/tests/bug78456.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Bug #78456: Segfault when serializing SplDoublyLinkedList
3+
--FILE--
4+
<?php
5+
6+
$dllist = new SplDoublyLinkedList();
7+
$dllist->push(new stdClass);
8+
var_dump($s = serialize($dllist));
9+
var_dump(unserialize($s));
10+
11+
?>
12+
--EXPECT--
13+
string(82) "O:19:"SplDoublyLinkedList":3:{i:0;i:0;i:1;a:1:{i:0;O:8:"stdClass":0:{}}i:2;a:0:{}}"
14+
object(SplDoublyLinkedList)#3 (2) {
15+
["flags":"SplDoublyLinkedList":private]=>
16+
int(0)
17+
["dllist":"SplDoublyLinkedList":private]=>
18+
array(1) {
19+
[0]=>
20+
object(stdClass)#4 (0) {
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)