readline: free undo list associated with the saved history line when traversing history

This commit is contained in:
Chet Ramey
2021-07-12 11:09:44 -04:00
parent 5a0e5b7b28
commit 9e3495c9e9
6 changed files with 33 additions and 8 deletions
+2 -1
View File
@@ -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
View File
@@ -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;
}
+1 -2
View File
@@ -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