]> granicus.if.org Git - php/commitdiff
fix leak when call to shutdown function fails
authorAntony Dovgal <tony2001@php.net>
Fri, 15 Sep 2006 09:11:31 +0000 (09:11 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 15 Sep 2006 09:11:31 +0000 (09:11 +0000)
ext/standard/basic_functions.c
ext/standard/tests/general_functions/010.phpt [new file with mode: 0644]

index 7f4d06b62e209600f3b4341f9c6f1e6f95fecd92..f9782bf0a93ea769755170d107f48ec3cdbb3d87 100644 (file)
@@ -5214,16 +5214,20 @@ static int user_shutdown_function_call(php_shutdown_function_entry *shutdown_fun
 
        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;
 }
 
diff --git a/ext/standard/tests/general_functions/010.phpt b/ext/standard/tests/general_functions/010.phpt
new file mode 100644 (file)
index 0000000..8d1075f
--- /dev/null
@@ -0,0 +1,25 @@
+--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