Fixed bug #70573 (Cloning SplPriorityQueue leads to memory leaks)

This commit is contained in:
Dmitry Stogov 2015-09-24 16:42:59 +03:00
parent 6413ecb439
commit 415000ed93
3 changed files with 18 additions and 6 deletions

3
NEWS
View file

@ -43,6 +43,9 @@ PHP NEWS
- SQLite3: - SQLite3:
. Fixed bug #70571 (Memory leak in sqlite3_do_callback). (Adam) . Fixed bug #70571 (Memory leak in sqlite3_do_callback). (Adam)
-SPL:
. Fixed bug #70573 (Cloning SplPriorityQueue leads to memory leaks). (Dmitry)
- XMLRPC - XMLRPC
. Fixed bug #70526 (xmlrpc_set_type returns false on success). (Laruence) . Fixed bug #70526 (xmlrpc_set_type returns false on success). (Laruence)

View file

@ -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; intern->ce_get_iterator = other->ce_get_iterator;
if (clone_orig) { if (clone_orig) {
int i;
intern->heap = spl_ptr_heap_clone(other->heap); 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 { } else {
intern->heap = other->heap; intern->heap = other->heap;
} }

View file

@ -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