Skip to content

Commit 9483c50

Browse files
committed
Fixed bug #78456
1 parent bad49e5 commit 9483c50

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ PHP NEWS
1515
- SPL:
1616
. Fixed bug #78436 (Missing addref in SplPriorityQueue EXTR_BOTH mode).
1717
(Nikita)
18+
. Fixed bug #78456 (Segfault when serializing SplDoublyLinkedList). (Nikita)
1819

1920
22 Aug 2019, PHP 7.4.0beta4
2021

ext/spl/spl_dllist.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,7 @@ SPL_METHOD(SplDoublyLinkedList, __serialize)
12411241
array_init_size(&tmp, intern->llist->count);
12421242
while (current) {
12431243
zend_hash_next_index_insert(Z_ARRVAL(tmp), &current->data);
1244+
Z_TRY_ADDREF(current->data);
12441245
current = current->next;
12451246
}
12461247
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)