From 86bf55a3d898eda6c0d165eb019b17618e9f1442 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Wed, 30 Aug 2006 10:42:49 +0000 Subject: [PATCH] MFH: fix #38653 (memory leak in ReflectionClass::getConstant()) --- NEWS | 1 + ext/reflection/php_reflection.c | 2 ++ ext/reflection/tests/bug38653.phpt | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 ext/reflection/tests/bug38653.phpt diff --git a/NEWS b/NEWS index 947dd91d27..ca2206d843 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ PHP NEWS SoapServer::setClass() method). (Dmitry) - Added support for hexadecimal entity in imagettftext() for the bundled GD. (Pierre) +- Fixed bug #38653 (memory leak in ReflectionClass::getConstant()). (Tony) - Fixed bug #38637 (curl_copy_handle() fails to fully copy the cURL handle). (Tony, Ilia) - Fixed bug #38624 (Strange warning when incrementing an object property and diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 62d30956fb..33b0842301 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -211,6 +211,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) @@ -3224,6 +3225,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..68781d2aba --- /dev/null +++ b/ext/reflection/tests/bug38653.phpt @@ -0,0 +1,28 @@ +--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 -- 2.40.0