tony2001 Fri Sep 15 09:12:17 2006 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/standard/tests/general_functions 010.phpt
Modified files:
/php-src/ext/standard basic_functions.c
Log:
MFH: fix leak when call to shutdown function fails
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.725.2.31.2.23&r2=1.725.2.31.2.24&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.725.2.31.2.23
php-src/ext/standard/basic_functions.c:1.725.2.31.2.24
--- php-src/ext/standard/basic_functions.c:1.725.2.31.2.23 Thu Aug 31
14:41:23 2006
+++ php-src/ext/standard/basic_functions.c Fri Sep 15 09:12:16 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.725.2.31.2.23 2006/08/31 14:41:23 tony2001 Exp $
*/
+/* $Id: basic_functions.c,v 1.725.2.31.2.24 2006/09/15 09:12:16 tony2001 Exp $
*/
#include "php.h"
#include "php_streams.h"
@@ -5224,18 +5224,20 @@
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;
}
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