From bf89c5b891eb8e5f3cd6bfe3e7ce84243db7429b Mon Sep 17 00:00:00 2001 From: Brendan Cully Date: Mon, 12 Feb 2007 00:06:32 +0000 Subject: [PATCH] Do not attempt to free NULL IMAP headers after a partial mailbox load. --- imap/imap.c | 4 +++- imap/message.c | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/imap/imap.c b/imap/imap.c index 5a77f2f9..6344b4e9 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -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++) { diff --git a/imap/message.c b/imap/message.c index 586d362d..4fa6a0f6 100644 --- a/imap/message.c +++ b/imap/message.c @@ -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); -- 2.40.0