mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.2'
* PHP-8.2: Fix memory leak
This commit is contained in:
commit
7fdf896d4b
2 changed files with 32 additions and 2 deletions
23
Zend/tests/gc_046.phpt
Normal file
23
Zend/tests/gc_046.phpt
Normal file
|
@ -0,0 +1,23 @@
|
|||
--TEST--
|
||||
GC 046: Leak in User Iterator
|
||||
--INI--
|
||||
zend.enable_gc=1
|
||||
--FILE--
|
||||
<?php
|
||||
class Action {
|
||||
function __construct() {
|
||||
$this->iterator = new ArrayIterator($this);
|
||||
}
|
||||
function filter() {
|
||||
$this->iterator = new CallbackFilterIterator($this->iterator, fn() => true);
|
||||
$this->iterator->rewind();
|
||||
}
|
||||
}
|
||||
|
||||
$action=new Action;
|
||||
$action->filter();
|
||||
$action->filter();
|
||||
?>
|
||||
DONE
|
||||
--EXPECT--
|
||||
DONE
|
|
@ -184,8 +184,15 @@ ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter)
|
|||
ZEND_API HashTable *zend_user_it_get_gc(zend_object_iterator *_iter, zval **table, int *n)
|
||||
{
|
||||
zend_user_iterator *iter = (zend_user_iterator*)_iter;
|
||||
*table = &iter->it.data;
|
||||
*n = 1;
|
||||
if (Z_ISUNDEF(iter->value)) {
|
||||
*table = &iter->it.data;
|
||||
*n = 1;
|
||||
} else {
|
||||
zend_get_gc_buffer *gc_buffer = zend_get_gc_buffer_create();
|
||||
zend_get_gc_buffer_add_zval(gc_buffer, &iter->it.data);
|
||||
zend_get_gc_buffer_add_zval(gc_buffer, &iter->value);
|
||||
zend_get_gc_buffer_use(gc_buffer, table, n);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue