From 04da0582846db07dde5b6e5242ca80df9ea109cf Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Fri, 15 Sep 2006 09:12:17 +0000 Subject: [PATCH] MFH: fix leak when call to shutdown function fails --- ext/standard/basic_functions.c | 20 ++++++++------- ext/standard/tests/general_functions/010.phpt | 25 +++++++++++++++++++ 2 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 ext/standard/tests/general_functions/010.phpt diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index f59920f1b4..236fbd0106 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -5224,18 +5224,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 %s() - function does not exist", 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) + efree(function_name); + return 0; + } + efree(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); } - if (function_name) { - efree(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 index 0000000000..8d1075f842 --- /dev/null +++ b/ext/standard/tests/general_functions/010.phpt @@ -0,0 +1,25 @@ +--TEST-- +register_shutdown_function() & __call +--FILE-- + +--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 -- 2.40.0