com php-src: Fixed bug #78456: NEWS ext/spl/spl_dllist.c ext/spl/tests/bug78456.phpt
| From: | Nikita Popov | Date: | Mon, 26 Aug 2019 09:08:42 +0000 |
| Subject: | com php-src: Fixed bug #78456: NEWS ext/spl/spl_dllist.c ext/spl/tests/bug78456.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-108048@lists.php.net to get a copy of this message | ||
Commit: 9483c507725637a45704d5983f3eaf7ca37875c9
Author: Nikita Popov <nikita.ppv@gmail.com> Mon, 26 Aug 2019 11:08:42 +0200
Parents: bad49e55b94863153e890ff00d093e3a74627984
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9483c507725637a45704d5983f3eaf7ca37875c9
Log:
Fixed bug #78456
Bugs:
https://bugs.php.net/78456
Changed paths:
M NEWS
M ext/spl/spl_dllist.c
A ext/spl/tests/bug78456.phpt
Diff:
diff --git a/NEWS b/NEWS
index 69913fd..cac5b6b 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ PHP NEWS
- SPL:
. Fixed bug #78436 (Missing addref in SplPriorityQueue EXTR_BOTH mode).
(Nikita)
+ . Fixed bug #78456 (Segfault when serializing SplDoublyLinkedList). (Nikita)
22 Aug 2019, PHP 7.4.0beta4
diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c
index abada18..10aaa1c 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -1241,6 +1241,7 @@ SPL_METHOD(SplDoublyLinkedList, __serialize)
array_init_size(&tmp, intern->llist->count);
while (current) {
zend_hash_next_index_insert(Z_ARRVAL(tmp), ¤t->data);
+ Z_TRY_ADDREF(current->data);
current = current->next;
}
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
diff --git a/ext/spl/tests/bug78456.phpt b/ext/spl/tests/bug78456.phpt
new file mode 100644
index 0000000..e7cf50f
--- /dev/null
+++ b/ext/spl/tests/bug78456.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #78456: Segfault when serializing SplDoublyLinkedList
+--FILE--
+<?php
+
+$dllist = new SplDoublyLinkedList();
+$dllist->push(new stdClass);
+var_dump($s = serialize($dllist));
+var_dump(unserialize($s));
+
+?>
+--EXPECT--
+string(82)
"O:19:"SplDoublyLinkedList":3:{i:0;i:0;i:1;a:1:{i:0;O:8:"stdClass":0:{}}i:2;a:0:{}}"
+object(SplDoublyLinkedList)#3 (2) {
+ ["flags":"SplDoublyLinkedList":private]=>
+ int(0)
+ ["dllist":"SplDoublyLinkedList":private]=>
+ array(1) {
+ [0]=>
+ object(stdClass)#4 (0) {
+ }
+ }
+}