mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
- MFH: Fixed memory leaks in readline_completion_function()
This commit is contained in:
parent
d43b7b022f
commit
da067890db
@ -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);
|
||||
}
|
||||
|
||||
|
25
ext/readline/tests/readline_completion_function_001.phpt
Normal file
25
ext/readline/tests/readline_completion_function_001.phpt
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user