From 0b6b7666c95e00e971e540e1ca5c626954f45af1 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 26 Nov 2016 11:20:16 +0000 Subject: [PATCH] fix: index in pager crash The steps to reproduce this were: - open a mail - change the underlying maildir while the mail is open - reply to the mail I can't reproduce the original crash, but it happened when the index was being redrawn. One of the "Context->hdrs" was NULL causing index_make_entry to crash. --- curs_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/curs_main.c b/curs_main.c index ef4fd6928..32e3ed388 100644 --- a/curs_main.c +++ b/curs_main.c @@ -269,12 +269,15 @@ void mutt_ts_icon(char *str) void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num) { - if (!Context || !menu || (num < 0)) + if (!Context || !menu || (num < 0) || (num >= Context->hdrmax)) + return; + + HEADER *h = Context->hdrs[Context->v2r[num]]; + if (!h) return; format_flag flag = MUTT_FORMAT_MAKEPRINT | MUTT_FORMAT_ARROWCURSOR | MUTT_FORMAT_INDEX; int edgemsgno, reverse = Sort & SORT_REVERSE; - HEADER *h = Context->hdrs[Context->v2r[num]]; THREAD *tmp; if ((Sort & SORT_MASK) == SORT_THREADS && h->tree) -- 2.40.0