]> granicus.if.org Git - php/commitdiff
- Fixed bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with constant...
authorFelipe Pena <felipe@php.net>
Tue, 25 May 2010 22:46:17 +0000 (22:46 +0000)
committerFelipe Pena <felipe@php.net>
Tue, 25 May 2010 22:46:17 +0000 (22:46 +0000)
NEWS
ext/reflection/php_reflection.c
ext/reflection/tests/bug51911.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index d6d58fcdde60033d8128077b79383816a43b3c34..e9f13c93bb581b8f8a4412656dd2d00ae826f57a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -62,6 +62,8 @@ PHP                                                                        NEWS
   requests (Fixes CVE-2010-0397, bug #51288). (Raphael Geissert)
 - Fixed 64-bit integer overflow in mhash_keygen_s2k(). (ClĂ©ment LECIGNE, Stas)
 
+- Fixed bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with
+  constant array). (Felipe)
 - Fixed bug #51844 (checkdnsrr does not support types other than MX). (Pierre)
 - Fixed bug #51827 (Bad warning when register_shutdown_function called with
   wrong num of parameters). (Felipe)
index 98928b3b0e151415f88e50a6a66a2f57beb35959..6a35bf54c24dbc8175330eb759bc2c7d463b4e88 100644 (file)
@@ -2408,7 +2408,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 (file)
index 0000000..12eb459
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with constant array)
+--FILE--
+<?php
+
+class Foo {
+   const X = 1;
+   public function x($x = array(1)) {}
+}
+
+$clazz = new ReflectionClass('Foo');
+$method = $clazz->getMethod('x');
+foreach ($method->getParameters() as $param) {
+    if ( $param->isDefaultValueAvailable())
+        echo '$', $param->getName(), ' : ', var_export($param->getDefaultValue(), 1), "\n";
+}
+
+?>
+--EXPECT--
+$x : array (
+  0 => 1,
+)