Ticket #1936: segfault in input line history.

If input line history contains only one item, pressing M-p
("Previous history item") causes a segmentation fault.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-01-05 11:27:21 +03:00
parent 287255b2ed
commit 6d9e319106

View File

@ -1702,18 +1702,20 @@ assign_text (WInput *in, const char *text)
static void
hist_prev (WInput *in)
{
GList *prev;
if (!in->history)
return;
if (in->need_push) {
if (in->need_push)
push_history (in, in->buffer);
in->history = g_list_previous (in->history);
} else if (in->history->prev)
in->history = g_list_previous (in->history);
else
return;
assign_text (in, (char *) in->history->data);
in->need_push = 0;
prev = g_list_previous (in->history);
if (prev != NULL) {
in->history = prev;
assign_text (in, (char *) prev->data);
in->need_push = 0;
}
}
static void