tony2001                Wed Oct 11 15:51:17 2006 UTC

  Added files:                 
    /php-src/ext/reflection/tests       009.phpt 

  Modified files:              
    /php-src/ext/reflection     php_reflection.c 
    /php-src/ext/reflection/tests       bug39067.phpt 
  Log:
  fix #39125 (Memleak when reflecting non-existing class/method)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.260&r2=1.261&diff_format=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.260 
php-src/ext/reflection/php_reflection.c:1.261
--- php-src/ext/reflection/php_reflection.c:1.260       Fri Oct  6 18:02:50 2006
+++ php-src/ext/reflection/php_reflection.c     Wed Oct 11 15:51:17 2006
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_reflection.c,v 1.260 2006/10/06 18:02:50 tony2001 Exp $ */
+/* $Id: php_reflection.c,v 1.261 2006/10/11 15:51:17 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -2180,6 +2180,7 @@
                }
                /* FIXME: Unicode support??? */
                if ((tmp = strstr(name_str.s, "::")) == NULL) {
+                       zend_throw_exception_ex(reflection_exception_ptr, 0 
TSRMLS_CC, "Invalid method name %s", name_str);
                        return;
                }
                type = IS_STRING;
@@ -2203,6 +2204,9 @@
                        if (zend_u_lookup_class(Z_TYPE_P(classname), 
Z_UNIVAL_P(classname), Z_UNILEN_P(classname), &pce TSRMLS_CC) == FAILURE) {
                                
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
                                                "Class %v does not exist", 
Z_UNIVAL_P(classname)); 
+                               if (classname == &ztmp) {
+                                       zval_dtor(&ztmp);
+                               }
                                return;
                        }
                        ce = *pce;
@@ -2213,6 +2217,9 @@
                        break;
 
                default:
+                       if (classname == &ztmp) {
+                               zval_dtor(&ztmp);
+                       }
                        _DO_THROW("The parameter class is expected to be either 
a string or an object");
                        /* returns out of this function */
        }
@@ -4913,7 +4920,7 @@
        php_info_print_table_start();
        php_info_print_table_header(2, "Reflection", "enabled");
 
-       php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.260 
2006/10/06 18:02:50 tony2001 Exp $");
+       php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.261 
2006/10/11 15:51:17 tony2001 Exp $");
 
        php_info_print_table_end();
 } /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/bug39067.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/reflection/tests/bug39067.phpt
diff -u php-src/ext/reflection/tests/bug39067.phpt:1.2 
php-src/ext/reflection/tests/bug39067.phpt:1.3
--- php-src/ext/reflection/tests/bug39067.phpt:1.2      Fri Oct  6 18:02:50 2006
+++ php-src/ext/reflection/tests/bug39067.phpt  Wed Oct 11 15:51:17 2006
@@ -47,5 +47,5 @@
 unicode(1) "C"
 unicode(1) "B"
 unicode(1) "A"
-unicode(4) "Test2"
+unicode(5) "Test2"
 Done

http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/009.phpt?view=markup&rev=1.1
Index: php-src/ext/reflection/tests/009.phpt
+++ php-src/ext/reflection/tests/009.phpt
--TEST--
ReflectionMethod::__construct() tests
--FILE--
<?php

$a = array("", 1, "::", "a::", "::b", "a::b");

foreach ($a as $val) {
        try {
                new ReflectionMethod($val);
        } catch (Exception $e) {
                var_dump($e->getMessage());
        }
}
 
$a = array("", 1, "");
$b = array("", "", 1);
 
foreach ($a as $key=>$val) {
        try {
                new ReflectionMethod($val, $b[$key]);
        } catch (Exception $e) {
                var_dump($e->getMessage());
        }
}

echo "Done\n";
?>
--EXPECTF--     
string(20) "Invalid method name "
string(21) "Invalid method name 1"
string(21) "Class  does not exist"
string(22) "Class a does not exist"
string(21) "Class  does not exist"
string(22) "Class a does not exist"
string(21) "Class  does not exist"
string(66) "The parameter class is expected to be either a string or an object"
string(21) "Class  does not exist"
Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to