summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-09-24 16:42:59 +0300
committerDmitry Stogov <dmitry@zend.com>2015-09-24 16:42:59 +0300
commit415000ed93c6811cbceae3344d76ec63dbd7fff3 (patch)
tree717f0a5cb1697f95bfa101e7fea4d7f0ba0624fd
parent6413ecb4390d6b0f5e452a5d8f72f847fb04fa04 (diff)
downloadphp-git-415000ed93c6811cbceae3344d76ec63dbd7fff3.tar.gz
Fixed bug #70573 (Cloning SplPriorityQueue leads to memory leaks)
-rw-r--r--NEWS3
-rw-r--r--ext/spl/spl_heap.c6
-rw-r--r--ext/spl/tests/bug70573.phpt15
3 files changed, 18 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 92230eabdb..76c2943dad 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 ad520f948a..ddcfbb1168 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 0000000000..b93e48876d
--- /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
+
+