mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-01 09:29:51 +02:00
readline: free undo list associated with the saved history line when traversing history
This commit is contained in:
@@ -10696,3 +10696,20 @@ support/Makefile.in
|
||||
{,builtins}/Makefile.in, lib/{sh,readline,malloc,glob}/Makefile.in
|
||||
- use STYLE_CFLAGS so specifying CFLAGS=-g to make doesn't clutter the
|
||||
output with warnings about parens and format strings
|
||||
|
||||
7/9
|
||||
---
|
||||
lib/readline/search.c
|
||||
- make_history_line_current: call _rl_free_saved_history_line to clean
|
||||
up _rl_saved_line_from_history and get all the code that frees it
|
||||
into one place
|
||||
|
||||
lib/readline/misc.c
|
||||
- _rl_free_saved_history_line: if rl_undo_list points to the data
|
||||
member of _rl_saved_line_from_history, set it to NULL to avoid having
|
||||
it point to freed memory, since the next thing we do now is to free
|
||||
the undo list the data member points to
|
||||
- _rl_start_using_history: call _rl_free_saved_history_line instead of
|
||||
calling _rl_free_history_entry directly. Fixes memory leak reported
|
||||
by Trung Dam <trungdam@yahoo.com>
|
||||
|
||||
|
||||
+2
-1
@@ -934,7 +934,6 @@ rl_trim_arg_from_keyseq (const char *keyseq, size_t len, Keymap map)
|
||||
if (i + 1 == len)
|
||||
return -1;
|
||||
|
||||
map = map0;
|
||||
parsing_digits = 1;
|
||||
|
||||
/* This logic should be identical to rl_digit_loop */
|
||||
@@ -949,6 +948,8 @@ rl_trim_arg_from_keyseq (const char *keyseq, size_t len, Keymap map)
|
||||
{
|
||||
parsing_digits = 2;
|
||||
}
|
||||
|
||||
map = map0;
|
||||
j = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-2
@@ -306,8 +306,7 @@ _rl_start_using_history (void)
|
||||
{
|
||||
using_history ();
|
||||
if (_rl_saved_line_for_history)
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
|
||||
_rl_free_saved_history_line ();
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
@@ -352,6 +351,8 @@ rl_maybe_unsave_line (void)
|
||||
list from a history entry, as in rl_replace_from_history() below. */
|
||||
rl_replace_line (_rl_saved_line_for_history->line, 0);
|
||||
rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
|
||||
|
||||
/* Doesn't free `data'. */
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
rl_point = rl_end; /* rl_replace_line sets rl_end */
|
||||
@@ -381,6 +382,14 @@ _rl_free_saved_history_line (void)
|
||||
{
|
||||
if (_rl_saved_line_for_history)
|
||||
{
|
||||
if (rl_undo_list && rl_undo_list == (UNDO_LIST *)_rl_saved_line_for_history->data)
|
||||
rl_undo_list = 0;
|
||||
/* Have to free this separately because _rl_free_history entry can't:
|
||||
it doesn't know whether or not this has application data. Only the
|
||||
callers that know this is _rl_saved_line_for_history can know that
|
||||
it's an undo list. */
|
||||
if (_rl_saved_line_for_history->data)
|
||||
_rl_free_undo_list ((UNDO_LIST *)_rl_saved_line_for_history->data);
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
@@ -96,8 +96,7 @@ make_history_line_current (HIST_ENTRY *entry)
|
||||
#endif
|
||||
|
||||
if (_rl_saved_line_for_history)
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
_rl_free_saved_history_line ();
|
||||
}
|
||||
|
||||
/* Search the history list for STRING starting at absolute history position
|
||||
|
||||
@@ -989,8 +989,7 @@ comsub: DOLPAREN compound_list ')'
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
|
|
||||
DOLPAREN newline_list ')'
|
||||
| DOLPAREN newline_list ')'
|
||||
{
|
||||
$$ = (COMMAND *)NULL;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
BUILD_DIR=/usr/local/build/bash/bash-current
|
||||
BUILD_DIR=/usr/local/build/chet/bash/bash-current
|
||||
THIS_SH=$BUILD_DIR/bash
|
||||
PATH=$PATH:$BUILD_DIR
|
||||
|
||||
|
||||
Reference in New Issue
Block a user