From: Felipe Pena Date: Thu, 20 Nov 2008 22:25:37 +0000 (+0000) Subject: - MFH: Fixed memory leaks in readline_completion_function() X-Git-Tag: php-5.3.0alpha2~118 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da067890db16358c0e69a83e78dfed6f93c6183e;p=php - MFH: Fixed memory leaks in readline_completion_function() --- diff --git a/ext/readline/readline.c b/ext/readline/readline.c index b8dbb535d6..766a9d79de 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -169,8 +169,10 @@ PHP_MINIT_FUNCTION(readline) PHP_RSHUTDOWN_FUNCTION(readline) { - if (_readline_completion) + if (_readline_completion) { + zval_dtor(_readline_completion); FREE_ZVAL(_readline_completion); + } #if HAVE_RL_CALLBACK_READ_CHAR if (_prepped_callback) { rl_callback_handler_remove(); @@ -491,8 +493,10 @@ PHP_FUNCTION(readline_completion_function) efree(name); RETURN_FALSE; } + efree(name); if (_readline_completion) { + zval_dtor(_readline_completion); FREE_ZVAL(_readline_completion); } diff --git a/ext/readline/tests/readline_completion_function_001.phpt b/ext/readline/tests/readline_completion_function_001.phpt new file mode 100644 index 0000000000..828636cd83 --- /dev/null +++ b/ext/readline/tests/readline_completion_function_001.phpt @@ -0,0 +1,25 @@ +--TEST-- +readline_completion_function(): Basic test +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: readline_completion_function(): 1 is not callable in %s on line %d + +Warning: readline_completion_function(): 1.1231 is not callable in %s on line %d