]> 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 e7d918113992fb6147d8ea72ee75ecb04952b230..cc6717566bee66983ac904e6f675a6ef98f1dcfa 100644 (file)
--- 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
index 91ac82b14d40f94fd43dbced693c4244dc792585..08ecc2b4eb675ba27e7ecfdb787fc3bdbd57fec8 100644 (file)
@@ -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 (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,
+)