mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Merge branch 'PHP-8.1'
* PHP-8.1: Fix memory leak
This commit is contained in:
commit
7451b8b6b0
@ -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);
|
||||
|
11
ext/reflection/tests/ReflectionClass_getMethods_004.phpt
Normal file
11
ext/reflection/tests/ReflectionClass_getMethods_004.phpt
Normal file
@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
ReflectionClass::getMethods()
|
||||
--FILE--
|
||||
<?php
|
||||
$l = function() {};
|
||||
$o=new ReflectionObject($l);
|
||||
$o->getMethods(2);
|
||||
?>
|
||||
DONE
|
||||
--EXPECT--
|
||||
DONE
|
Loading…
Reference in New Issue
Block a user