diff options
author | Felipe Pena <felipe@php.net> | 2010-05-25 22:46:17 +0000 |
---|---|---|
committer | Felipe Pena <felipe@php.net> | 2010-05-25 22:46:17 +0000 |
commit | 1168cdc323af8955036f032c5f3e13cfe85f027b (patch) | |
tree | 4423ecf8f872d1295fc9ad6bad7c2324800bf5ed | |
parent | 708b31a5108d9b1b5c6bec340ce0110a18cbbdde (diff) | |
download | php-git-1168cdc323af8955036f032c5f3e13cfe85f027b.tar.gz |
- Fixed bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with constant array)
-rw-r--r-- | ext/reflection/php_reflection.c | 2 | ||||
-rw-r--r-- | ext/reflection/tests/bug51911.phpt | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 12594c91a8..d7e9c0ebc9 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2567,7 +2567,7 @@ ZEND_METHOD(reflection_parameter, getDefaultValue) *return_value = *precv->op2.zv; 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-- +<?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, +) |