com php-src: Fixed bug #70573 (Cloning SplPriorityQueue leads to memory leaks): NEWS ext/spl/spl_heap.c ext/spl/tests/bug70 573.phpt
| From: | Dmitry Stogov | Date: | Thu, 24 Sep 2015 13:42:59 +0000 |
| Subject: | com php-src: Fixed bug #70573 (Cloning SplPriorityQueue leads to memory leaks): NEWS ext/spl/spl_heap.c ext/spl/tests/bug70 573.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89158@lists.php.net to get a copy of this message | ||
Commit: 415000ed93c6811cbceae3344d76ec63dbd7fff3
Author: Dmitry Stogov <dmitry@zend.com> Thu, 24 Sep 2015 16:42:59 +0300
Parents: 6413ecb4390d6b0f5e452a5d8f72f847fb04fa04
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=415000ed93c6811cbceae3344d76ec63dbd7fff3
Log:
Fixed bug #70573 (Cloning SplPriorityQueue leads to memory leaks)
Bugs:
https://bugs.php.net/70573
Changed paths:
M NEWS
M ext/spl/spl_heap.c
A ext/spl/tests/bug70573.phpt
Diff:
diff --git a/NEWS b/NEWS
index 92230ea...76c2943 100644
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,9 @@ PHP NEWS
- SQLite3:
. Fixed bug #70571 (Memory leak in sqlite3_do_callback). (Adam)
+-SPL:
+ . Fixed bug #70573 (Cloning SplPriorityQueue leads to memory leaks). (Dmitry)
+
- XMLRPC
. Fixed bug #70526 (xmlrpc_set_type returns false on success). (Laruence)
diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c
index ad520f9..ddcfbb1 100644
--- a/ext/spl/spl_heap.c
+++ b/ext/spl/spl_heap.c
@@ -378,13 +378,7 @@ static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zval
*o
intern->ce_get_iterator = other->ce_get_iterator;
if (clone_orig) {
- int i;
intern->heap = spl_ptr_heap_clone(other->heap);
- for (i = 0; i < intern->heap->count; ++i) {
- if (Z_REFCOUNTED(intern->heap->elements[i])) {
- Z_ADDREF(intern->heap->elements[i]);
- }
- }
} else {
intern->heap = other->heap;
}
diff --git a/ext/spl/tests/bug70573.phpt b/ext/spl/tests/bug70573.phpt
new file mode 100644
index 0000000..b93e488
--- /dev/null
+++ b/ext/spl/tests/bug70573.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #70573 (Cloning SplPriorityQueue leads to memory leaks)
+--FILE--
+<?php
+$q1 = new SplPriorityQueue();
+$a = 1;
+$q1->insert([$a], 1);
+$q1->insert([$a], 2);
+$q2 = clone $q1;
+echo "ok\n";
+?>
+--EXPECT--
+ok
+
+