diff options
| author | Felipe Pena <felipe@php.net> | 2008-11-20 22:26:32 +0000 |
|---|---|---|
| committer | Felipe Pena <felipe@php.net> | 2008-11-20 22:26:32 +0000 |
| commit | 22851007ca8ff33274e844ad08706cb4e22d6d02 (patch) | |
| tree | 57a5cfdcf3adea3528bafdb3885a069c96c770a8 | |
| parent | 2b251dc6031830fc3e7212218a426fe8560b6610 (diff) | |
| download | php-git-22851007ca8ff33274e844ad08706cb4e22d6d02.tar.gz | |
- MFH: Fixed memory leaks in readline_completion_function()
| -rw-r--r-- | ext/readline/readline.c | 9 | ||||
| -rw-r--r-- | ext/readline/tests/readline_completion_function_001.phpt | 25 |
2 files changed, 32 insertions, 2 deletions
diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 9060a62464..3a481dfa4c 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -115,8 +115,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(); @@ -456,9 +458,12 @@ PHP_FUNCTION(readline_completion_function) efree(name); RETURN_FALSE; } + efree(name); - if (_readline_completion) + if (_readline_completion) { + zval_dtor(_readline_completion); FREE_ZVAL(_readline_completion); + } MAKE_STD_ZVAL(_readline_completion); *_readline_completion = *arg; 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-- +<?php if (!extension_loaded("readline")) die("skip"); ?> +--FILE-- +<?php + +function foo() { } + +$data = array( + 'foo', + 'strtolower', + 1, + 1.1231 +); + +foreach ($data as $callback) { + readline_completion_function($callback); +} + +?> +--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 |
