Skip to content

Fix GH-17154: Memory leak on rl_line_buffer when no history (libedit). #17155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: PHP-8.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ext/readline/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ ZEND_GET_MODULE(readline)

PHP_MINIT_FUNCTION(readline)
{
#if HAVE_LIBREADLINE
/* libedit don't need this call which set the tty in cooked mode */
using_history();
#endif
ZVAL_UNDEF(&_readline_completion);
#if HAVE_RL_CALLBACK_READ_CHAR
ZVAL_UNDEF(&_prepped_callback);
Expand Down
12 changes: 12 additions & 0 deletions ext/readline/tests/gh17154.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
GH-17154 readline_write_history()/readline_read_history(): memory leak
--EXTENSIONS--my
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--EXTENSIONS--my
--EXTENSIONS--

readline
--FILE--
<?php
readline_info('line_buffer', 'val');
readline_write_history("myhistory");
var_dump(readline_read_history("myhistory"));
?>
--EXPECTF--
bool(true)
Loading