dmitry Wed Oct 1 07:30:52 2008 UTC Modified files: /php-src/ext/reflection php_reflection.c /php-src/ext/reflection/tests bug46205.phpt Log: Fixed bug #46205 (Closure - Memory leaks when ReflectionException is thrown) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.318&r2=1.319&diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.318 php-src/ext/reflection/php_reflection.c:1.319 --- php-src/ext/reflection/php_reflection.c:1.318 Fri Aug 22 15:51:50 2008 +++ php-src/ext/reflection/php_reflection.c Wed Oct 1 07:30:52 2008 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reflection.c,v 1.318 2008/08/22 15:51:50 felipe Exp $ */ +/* $Id: php_reflection.c,v 1.319 2008/10/01 07:30:52 dmitry Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -2005,6 +2005,12 @@ 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 */ } @@ -2023,6 +2029,12 @@ } } 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 */ } @@ -5416,7 +5428,7 @@ php_info_print_table_start(); php_info_print_table_header(2, "Reflection", "enabled"); - php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.318 2008/08/22 15:51:50 felipe Exp $"); + php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.319 2008/10/01 07:30:52 dmitry Exp $"); php_info_print_table_end(); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/bug46205.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/bug46205.phpt diff -u /dev/null php-src/ext/reflection/tests/bug46205.phpt:1.2 --- /dev/null Wed Oct 1 07:30:52 2008 +++ php-src/ext/reflection/tests/bug46205.phpt Wed Oct 1 07:30:52 2008 @@ -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
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php