Merge branch 'PHP-8.1'

* PHP-8.1:
  Fix memory leak
This commit is contained in:
Dmitry Stogov 2022-06-06 11:38:37 +03:00
commit 7451b8b6b0
2 changed files with 18 additions and 3 deletions

View File

@ -4409,17 +4409,19 @@ ZEND_METHOD(ReflectionClass, getMethod)
/* }}} */
/* {{{ _addmethod */
static void _addmethod(zend_function *mptr, zend_class_entry *ce, HashTable *ht, zend_long filter)
static bool _addmethod(zend_function *mptr, zend_class_entry *ce, HashTable *ht, zend_long filter)
{
if ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) && mptr->common.scope != ce) {
return;
return 0;
}
if (mptr->common.fn_flags & filter) {
zval method;
reflection_method_factory(ce, mptr, NULL, &method);
zend_hash_next_index_insert_new(ht, &method);
return 1;
}
return 0;
}
/* }}} */
@ -4459,7 +4461,9 @@ ZEND_METHOD(ReflectionClass, getMethods)
}
zend_function *closure = zend_get_closure_invoke_method(obj);
if (closure) {
_addmethod(closure, ce, Z_ARRVAL_P(return_value), filter);
if (!_addmethod(closure, ce, Z_ARRVAL_P(return_value), filter)) {
_free_function(closure);
}
}
if (!has_obj) {
zval_ptr_dtor(&obj_tmp);

View File

@ -0,0 +1,11 @@
--TEST--
ReflectionClass::getMethods()
--FILE--
<?php
$l = function() {};
$o=new ReflectionObject($l);
$o->getMethods(2);
?>
DONE
--EXPECT--
DONE