From 9c129ed87fbc6981ad6fd5a51901beed14bec802 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Mon, 12 Feb 2007 00:56:36 +0000 Subject: [PATCH] Full fix for null-pointer dereferences on partial opens. Thanks also to Ken Brush. --- imap/imap.c | 2 +- thread.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/imap/imap.c b/imap/imap.c index 6344b4e9..1e2019e4 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 b3bf5f76..3612a3c7 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; -- 2.40.0