From: Kees Cook Date: Mon, 12 Feb 2007 00:56:36 +0000 (+0000) Subject: Full fix for null-pointer dereferences on partial opens. Thanks also X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3d6752969edba83efbc3e7b0591cc479371e5ab;p=neomutt Full fix for null-pointer dereferences on partial opens. Thanks also to Ken Brush. --- diff --git a/imap/imap.c b/imap/imap.c index 6344b4e94..1e2019e4d 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1301,7 +1301,7 @@ void imap_close_mailbox (CONTEXT* ctx) /* free IMAP part of headers */ for (i = 0; i < ctx->msgcount; i++) /* mailbox may not have fully loaded */ - if (ctx->hdrs[i]->data) + if (ctx->hdrs[i] && ctx->hdrs[i]->data) imap_free_header_data (&(ctx->hdrs[i]->data)); for (i = 0; i < IMAP_CACHE_LEN; i++) diff --git a/thread.c b/thread.c index b3bf5f76e..3612a3c75 100644 --- a/thread.c +++ b/thread.c @@ -555,8 +555,12 @@ void mutt_clear_threads (CONTEXT *ctx) for (i = 0; i < ctx->msgcount; i++) { - ctx->hdrs[i]->thread = NULL; - ctx->hdrs[i]->threaded = 0; + /* mailbox may have been only partially read */ + if (ctx->hdrs[i]) + { + ctx->hdrs[i]->thread = NULL; + ctx->hdrs[i]->threaded = 0; + } } ctx->tree = NULL;