]> granicus.if.org Git - mutt/commitdiff
Do not attempt to free NULL IMAP headers after a partial mailbox load.
authorBrendan Cully <brendan@kublai.com>
Mon, 12 Feb 2007 00:06:32 +0000 (00:06 +0000)
committerBrendan Cully <brendan@kublai.com>
Mon, 12 Feb 2007 00:06:32 +0000 (00:06 +0000)
imap/imap.c
imap/message.c

index 5a77f2f911a21a0222be0917b4cbe7e331393fa3..6344b4e940a65bc457f50f59dccfa6df9b2eeeba 100644 (file)
@@ -1300,7 +1300,9 @@ void imap_close_mailbox (CONTEXT* ctx)
 
   /* free IMAP part of headers */
   for (i = 0; i < ctx->msgcount; i++)
-    imap_free_header_data (&(ctx->hdrs[i]->data));
+    /* mailbox may not have fully loaded */
+    if (ctx->hdrs[i]->data)
+      imap_free_header_data (&(ctx->hdrs[i]->data));
 
   for (i = 0; i < IMAP_CACHE_LEN; i++)
   {
index 586d362d6baf42bc4ab10ab161a6b6690763bffa..4fa6a0f6f21b59a81a2675045cb74f74256b19cf 100644 (file)
@@ -193,7 +193,7 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
        else
          /* bad header in the cache, we'll have to refetch.
           * TODO: consider the possibility of a holey cache. */
-         imap_free_header_data((void**) &h.data);
+          imap_free_header_data((void**) &h.data);
   
         FREE(&uid_validity);
       }
@@ -202,7 +202,8 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
         break;
       if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK)))
       {
-        imap_free_header_data ((void**) &h.data);
+        if (h.data)
+          imap_free_header_data ((void**) &h.data);
         fclose (fp);
         mutt_hcache_close (hc);
         return -1;
@@ -303,7 +304,8 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
 
     if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK)))
     {
-      imap_free_header_data ((void**) &h.data);
+      if (h.data)
+        imap_free_header_data ((void**) &h.data);
       fclose (fp);
 #if USE_HCACHE
       mutt_hcache_close (hc);