Skip to content

Commit

Permalink
Handle history additions properly, by Andreas Schwab.
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3835 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
ths committed Dec 17, 2007
1 parent 6240d64 commit ccf7aa5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ static void term_hist_add(const char *cmdline)
new_entry = hist_entry;
/* Put this entry at the end of history */
memmove(&term_history[idx], &term_history[idx + 1],
&term_history[TERM_MAX_CMDS] - &term_history[idx + 1]);
(TERM_MAX_CMDS - idx + 1) * sizeof(char *));
term_history[TERM_MAX_CMDS - 1] = NULL;
for (; idx < TERM_MAX_CMDS; idx++) {
if (term_history[idx] == NULL)
Expand All @@ -280,7 +280,7 @@ static void term_hist_add(const char *cmdline)
/* Need to get one free slot */
free(term_history[0]);
memcpy(term_history, &term_history[1],
&term_history[TERM_MAX_CMDS] - &term_history[1]);
(TERM_MAX_CMDS - 1) * sizeof(char *));
term_history[TERM_MAX_CMDS - 1] = NULL;
idx = TERM_MAX_CMDS - 1;
}
Expand Down

0 comments on commit ccf7aa5

Please sign in to comment.