Commit ccf7aa52aad631e1db1bbda8f3a3784ef3cd182b

Authored by ths
1 parent 6240d646

Handle history additions properly, by Andreas Schwab.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3835 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 2 additions and 2 deletions
readline.c
... ... @@ -267,7 +267,7 @@ static void term_hist_add(const char *cmdline)
267 267 new_entry = hist_entry;
268 268 /* Put this entry at the end of history */
269 269 memmove(&term_history[idx], &term_history[idx + 1],
270   - &term_history[TERM_MAX_CMDS] - &term_history[idx + 1]);
  270 + (TERM_MAX_CMDS - idx + 1) * sizeof(char *));
271 271 term_history[TERM_MAX_CMDS - 1] = NULL;
272 272 for (; idx < TERM_MAX_CMDS; idx++) {
273 273 if (term_history[idx] == NULL)
... ... @@ -280,7 +280,7 @@ static void term_hist_add(const char *cmdline)
280 280 /* Need to get one free slot */
281 281 free(term_history[0]);
282 282 memcpy(term_history, &term_history[1],
283   - &term_history[TERM_MAX_CMDS] - &term_history[1]);
  283 + (TERM_MAX_CMDS - 1) * sizeof(char *));
284 284 term_history[TERM_MAX_CMDS - 1] = NULL;
285 285 idx = TERM_MAX_CMDS - 1;
286 286 }
... ...