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 static void
hist_prev (WInput *in) hist_prev (WInput *in)
{ {
GList *prev;
if (!in->history) if (!in->history)
return; return;
if (in->need_push) { if (in->need_push)
push_history (in, in->buffer); push_history (in, in->buffer);
in->history = g_list_previous (in->history);
} else if (in->history->prev) prev = g_list_previous (in->history);
in->history = g_list_previous (in->history); if (prev != NULL) {
else in->history = prev;
return; assign_text (in, (char *) prev->data);
assign_text (in, (char *) in->history->data); in->need_push = 0;
in->need_push = 0; }
} }
static void static void