From: Antony Dovgal Date: Wed, 30 Aug 2006 10:41:43 +0000 (+0000) Subject: fix #38653 (memory leak in ReflectionClass::getConstant()) X-Git-Tag: RELEASE_1_0_0RC1~1847 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dcbbae86eb4d1173331f0c2234432a6936ccb41f;p=php fix #38653 (memory leak in ReflectionClass::getConstant()) --- diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index e75cadea1b..24eea39a0f 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -206,6 +206,7 @@ static void _default_get_entry(zval *object, char *name, int name_len, zval *ret *return_value = **value; zval_copy_ctor(return_value); + INIT_PZVAL(return_value); } static void reflection_register_implement(zend_class_entry *class_entry, zend_class_entry *interface_entry TSRMLS_DC) @@ -3261,6 +3262,7 @@ ZEND_METHOD(reflection_class, getConstant) } *return_value = **value; zval_copy_ctor(return_value); + INIT_PZVAL(return_value); } /* }}} */ diff --git a/ext/reflection/tests/bug38653.phpt b/ext/reflection/tests/bug38653.phpt new file mode 100644 index 0000000000..48f1c6ce41 --- /dev/null +++ b/ext/reflection/tests/bug38653.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #38653 (memory leak in ReflectionClass::getConstant()) +--FILE-- +getConstant("cons")); +var_dump($foo->getConstant("cons1")); +var_dump($foo->getConstant("cons2")); +var_dump($foo->getConstant("no such const")); + +echo "Done\n"; +?> +--EXPECTF-- +int(10) +string(0) "" +string(4) "test" +bool(false) +Done +--UEXPECTF-- +int(10) +unicode(0) "" +unicode(4) "test" +bool(false) +Done