summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2008-10-01 07:30:31 +0000
committerDmitry Stogov <dmitry@php.net>2008-10-01 07:30:31 +0000
commitf656c6fc70dedb3a2b62e9604396a1b82e32314c (patch)
tree572fcedefa9f8ca139291568ccdd7a97b5939108 /ext/reflection
parenta16bcaeb4bb714b867dd255bfe05801048d9ce2a (diff)
downloadphp-git-f656c6fc70dedb3a2b62e9604396a1b82e32314c.tar.gz
Fixed bug #46205 (Closure - Memory leaks when ReflectionException is thrown)
Diffstat (limited to 'ext/reflection')
-rw-r--r--ext/reflection/php_reflection.c12
-rw-r--r--ext/reflection/tests/bug46205.phpt14
2 files changed, 26 insertions, 0 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 73cdbea5d4..aac558d993 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -1975,6 +1975,12 @@ ZEND_METHOD(reflection_parameter, __construct)
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);
+ }
+ efree(fptr);
+ }
_DO_THROW("The parameter specified by its offset could not be found");
/* returns out of this function */
}
@@ -1990,6 +1996,12 @@ ZEND_METHOD(reflection_parameter, __construct)
}
}
if (position == -1) {
+ if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) {
+ if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
+ efree(fptr->common.function_name);
+ }
+ efree(fptr);
+ }
_DO_THROW("The parameter specified by its name could not be found");
/* returns out of this function */
}
diff --git a/ext/reflection/tests/bug46205.phpt b/ext/reflection/tests/bug46205.phpt
new file mode 100644
index 0000000000..ef7a692cb7
--- /dev/null
+++ b/ext/reflection/tests/bug46205.phpt
@@ -0,0 +1,14 @@
+--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