tony2001                Fri Sep 15 09:11:31 2006 UTC

  Added files:                 
    /php-src/ext/standard/tests/general_functions       010.phpt 

  Modified files:              
    /php-src/ext/standard       basic_functions.c 
  Log:
  fix leak when call to shutdown function fails
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.801&r2=1.802&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.801 
php-src/ext/standard/basic_functions.c:1.802
--- php-src/ext/standard/basic_functions.c:1.801        Thu Aug 31 14:41:15 2006
+++ php-src/ext/standard/basic_functions.c      Fri Sep 15 09:11:31 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.801 2006/08/31 14:41:15 tony2001 Exp $ */
+/* $Id: basic_functions.c,v 1.802 2006/09/15 09:11:31 tony2001 Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -5214,16 +5214,20 @@
 
        if (!zend_is_callable(shutdown_function_entry->arguments[0], 0, 
&function_name)) {
                php_error(E_WARNING, "(Registered shutdown functions) Unable to 
call %R() - function does not exist", Z_TYPE(function_name), 
Z_UNIVAL(function_name));
-       } else if (call_user_function(EG(function_table), NULL,
-                                                               
shutdown_function_entry->arguments[0],
-                                                               &retval, 
-                                                               
shutdown_function_entry->arg_count - 1,
-                                                               
shutdown_function_entry->arguments + 1 
-                                                               TSRMLS_CC ) == 
SUCCESS)
+               zval_dtor(&function_name);
+               return 0;
+       } 
+       zval_dtor(&function_name);
+       
+       if (call_user_function(EG(function_table), NULL,
+                               shutdown_function_entry->arguments[0],
+                               &retval, 
+                               shutdown_function_entry->arg_count - 1,
+                               shutdown_function_entry->arguments + 1 
+                               TSRMLS_CC ) == SUCCESS)
        {
                zval_dtor(&retval);
        } 
-       zval_dtor(&function_name);
        return 0;
 }
 

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/010.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/general_functions/010.phpt
+++ php-src/ext/standard/tests/general_functions/010.phpt
--TEST--
register_shutdown_function() & __call
--FILE--
<?php
class test {
        function _foo() {
                throw new Exception('test');
        }
        function __call($name=null, $args=null) {
                return test::_foo();
        }
}

var_dump(register_shutdown_function(array("test","__call")));

echo "Done\n";
?>
--EXPECTF--     
Strict Standards: Non-static method test::__call() cannot be called statically 
in %s on line %d
NULL
Done

Strict Standards: Non-static method test::__call() cannot be called statically 
in Unknown on line 0

Fatal error: Non-static method test::__call() cannot be called statically in 
Unknown on line 0

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

Reply via email to