From: Felipe Pena Date: Tue, 25 May 2010 22:46:17 +0000 (+0000) Subject: - Fixed bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with constant... X-Git-Tag: php-5.2.14RC1~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb43ac40d23f0e51430e65e1cf4980944b87b0a3;p=php - Fixed bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with constant array) --- diff --git a/NEWS b/NEWS index e7d9181139..cc6717566b 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,8 @@ PHP NEWS - Fixed a possible arbitrary memory access inside sqlite extension. Reported by Mateusz Kocielski. (Ilia) +- Fixed bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with + constant array). (Felipe) - Fixed bug #51671 (imagefill does not work correctly for small images). (Pierre) - Fixed bug #51670 (getColumnMeta causes segfault when re-executing query diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 91ac82b14d..08ecc2b4eb 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2170,7 +2170,7 @@ ZEND_METHOD(reflection_parameter, getDefaultValue) *return_value = precv->op2.u.constant; INIT_PZVAL(return_value); - if (Z_TYPE_P(return_value) != IS_CONSTANT) { + if (Z_TYPE_P(return_value) != IS_CONSTANT && Z_TYPE_P(return_value) != IS_CONSTANT_ARRAY) { zval_copy_ctor(return_value); } zval_update_constant_ex(&return_value, (void*)0, param->fptr->common.scope TSRMLS_CC); diff --git a/ext/reflection/tests/bug51911.phpt b/ext/reflection/tests/bug51911.phpt new file mode 100644 index 0000000000..12eb459fbc --- /dev/null +++ b/ext/reflection/tests/bug51911.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with constant array) +--FILE-- +getMethod('x'); +foreach ($method->getParameters() as $param) { + if ( $param->isDefaultValueAvailable()) + echo '$', $param->getName(), ' : ', var_export($param->getDefaultValue(), 1), "\n"; +} + +?> +--EXPECT-- +$x : array ( + 0 => 1, +)