diff options
| author | Felipe Pena <felipe@php.net> | 2008-11-20 22:23:53 +0000 |
|---|---|---|
| committer | Felipe Pena <felipe@php.net> | 2008-11-20 22:23:53 +0000 |
| commit | 4361a1ef277b54522e6c095cb7e06984bcda48c4 (patch) | |
| tree | 383bba2c5bf4106b13e84623dd866e9d2498b9fd | |
| parent | 2452619ed73525216270b7c4ee95eda184fb8719 (diff) | |
| download | php-git-4361a1ef277b54522e6c095cb7e06984bcda48c4.tar.gz | |
- Fixed memory leaks in readline_completion_function()
| -rw-r--r-- | ext/readline/readline.c | 5 | ||||
| -rw-r--r-- | ext/readline/tests/readline_completion_function_001.phpt | 25 |
2 files changed, 29 insertions, 1 deletions
diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 878affabc5..185492645b 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(); @@ -494,6 +496,7 @@ PHP_FUNCTION(readline_completion_function) zval_dtor(&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-- +<?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 |
