if (Z_TYPE_PP(parameter) == IS_LONG) {
position= Z_LVAL_PP(parameter);
if (position < 0 || (zend_uint)position >= fptr->common.num_args) {
+ if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) {
+ if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
+ efree(fptr->common.function_name.v);
+ }
+ efree(fptr);
+ }
_DO_THROW("The parameter specified by its offset could not be found");
/* returns out of this function */
}
}
}
if (position == -1) {
+ if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) {
+ if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
+ efree(fptr->common.function_name.v);
+ }
+ efree(fptr);
+ }
_DO_THROW("The parameter specified by its name could not be found");
/* returns out of this function */
}
--- /dev/null
+--TEST--
+Bug #46205 (Closure - Memory leaks when ReflectionException is thrown)
+--FILE--
+<?php
+$x = new reflectionmethod('reflectionparameter', 'export');
+$y = function() { };
+
+try {
+ $x->invokeArgs(new reflectionparameter('trim', 'str'), array($y, 1));
+} catch (Exception $e) { }
+?>
+ok
+--EXPECT--
+ok