]> granicus.if.org Git - neomutt/commitdiff
Full fix for null-pointer dereferences on partial opens. Thanks also
authorKees Cook <kees@outflux.net>
Mon, 12 Feb 2007 00:56:36 +0000 (00:56 +0000)
committerKees Cook <kees@outflux.net>
Mon, 12 Feb 2007 00:56:36 +0000 (00:56 +0000)
to Ken Brush.

imap/imap.c
thread.c

index 6344b4e940a65bc457f50f59dccfa6df9b2eeeba..1e2019e4d75d85b630de2dadee8a509503551c3a 100644 (file)
@@ -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++)
index b3bf5f76ea096d9c5a16575730e1d655e818e296..3612a3c755093c58f137f920b8115351a8a406c1 100644 (file)
--- 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;