]> granicus.if.org Git - php/commitdiff
MFH: fix #38653 (memory leak in ReflectionClass::getConstant())
authorAntony Dovgal <tony2001@php.net>
Wed, 30 Aug 2006 10:42:49 +0000 (10:42 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 30 Aug 2006 10:42:49 +0000 (10:42 +0000)
NEWS
ext/reflection/php_reflection.c
ext/reflection/tests/bug38653.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 947dd91d27f9c09ca324277db123ab9cd06138ad..ca2206d8432e5557472c3b4017a0f9b06c57b55d 100644 (file)
--- 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 
index 62d30956fbfc94a25e0290d91a5e9e92fc6cdd4a..33b0842301598d203b0f2f3201a4b3ba7e1c860d 100644 (file)
@@ -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 (file)
index 0000000..68781d2
--- /dev/null
@@ -0,0 +1,28 @@
+--TEST--
+Bug #38653 (memory leak in ReflectionClass::getConstant())
+--FILE--
+<?php
+
+class foo {
+           const cons = 10;
+           const cons1 = "";
+           const cons2 = "test";
+}
+
+class bar extends foo {
+}
+
+$foo = new ReflectionClass("foo");
+var_dump($foo->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