mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
Fixed bug #70573 (Cloning SplPriorityQueue leads to memory leaks)
This commit is contained in:
parent
6413ecb439
commit
415000ed93
3 changed files with 18 additions and 6 deletions
3
NEWS
3
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)
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
15
ext/spl/tests/bug70573.phpt
Normal file
15
ext/spl/tests/bug70573.phpt
Normal 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
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue