]> granicus.if.org Git - mutt/commitdiff
Fix a segfault in the new mboxcache hcache lookup.
authorBrendan Cully <brendan@kublai.com>
Mon, 2 Apr 2007 21:33:29 +0000 (14:33 -0700)
committerBrendan Cully <brendan@kublai.com>
Mon, 2 Apr 2007 21:33:29 +0000 (14:33 -0700)
idata may not have an associated context, so the cache path must use
the account info instead. For harmony with the other hcache callers,
make them all canonify the path the same way with imap_hcache_open.

imap/imap.c
imap/imap_private.h
imap/message.c
imap/util.c

index 25bf0472f86155db5b09a22279a93edb0cbf9ccd..ff939c1c81895d87809e8fbe551ff1585a50de19 100644 (file)
@@ -251,8 +251,8 @@ void imap_expunge_mailbox (IMAP_DATA* idata)
 #if USE_HCACHE
   header_cache_t *hc;
   char uidbuf[32];
-  
-  hc = mutt_hcache_open (HeaderCache, idata->ctx->path);
+
+  hc = imap_hcache_open (idata, idata->ctx->path);
 #endif
 
   for (i = 0; i < idata->ctx->msgcount; i++)
@@ -1157,7 +1157,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
 
 #if USE_HCACHE
   if (expunge && ctx->closing)
-    hc = mutt_hcache_open (HeaderCache, idata->ctx->path);
+    hc = imap_hcache_open (idata, idata->ctx->path);
 #endif
 
   /* save messages with real (non-flag) changes */
@@ -1582,7 +1582,6 @@ IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox, int create)
   char urlstr[LONG_STRING];
   unsigned int *uidvalidity = NULL;
   unsigned int *uidnext = NULL;
-  char* path;
 #endif
   
   for (cur = idata->mboxcache; cur; cur = cur->next)
@@ -1606,11 +1605,9 @@ IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox, int create)
   }
 
 #ifdef USE_HCACHE
-  path = safe_strdup (idata->ctx->path);
-  url_parse_ciss (&url, path);
+  mutt_account_tourl (&idata->conn->account, &url);
   url.path = (char*)mbox;
   url_ciss_tostring (&url, urlstr, sizeof (urlstr), 0);
-  FREE (&path);
   hc = mutt_hcache_open (HeaderCache, urlstr);
   if (hc)
   {
index c7a6b87624f0bbbe27dd6cd03f2f56169c66fda0..cf03859917b33b661eca18c7cf9a5f296672da35 100644 (file)
@@ -264,6 +264,10 @@ char* imap_set_flags (IMAP_DATA* idata, HEADER* h, char* s);
 int imap_cache_del (IMAP_DATA* idata, HEADER* h);
 
 /* util.c */
+#ifdef USE_HCACHE
+void* imap_hcache_open (IMAP_DATA* idata, const char* path);
+#endif
+
 int imap_continue (const char* msg, const char* resp);
 void imap_error (const char* where, const char* msg);
 IMAP_DATA* imap_new_idata (void);
index 5f9974188dcaef05ba5946126e1697e2b6044c56..51ed354da06036f7ece33052390aa6f5c4855199 100644 (file)
@@ -122,7 +122,7 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
 
 #if USE_HCACHE
   if (!msgbegin)
-    hc = mutt_hcache_open (HeaderCache, ctx->path);
+    hc = imap_hcache_open (idata, ctx->path);
 
   if (hc)
   {
index b2e85dfc74c416f729738acf047be90c02179b83..1af5a8907e937d488fde02e7efa7d4ad7f3df021 100644 (file)
@@ -66,6 +66,25 @@ int imap_expand_path (char* path, size_t len)
   return rc;
 }
 
+#ifdef USE_HCACHE
+void* imap_hcache_open (IMAP_DATA* idata, const char* path)
+{
+  IMAP_MBOX mx;
+  ciss_url_t url;
+  char cachepath[LONG_STRING];
+
+  if (imap_parse_path (path, &mx) < 0)
+    return NULL;
+
+  mutt_account_tourl (&idata->conn->account, &url);
+  url.path = mx.mbox;
+  url_ciss_tostring (&url, cachepath, sizeof (cachepath), 0);
+  FREE (&mx.mbox);
+
+  return mutt_hcache_open (HeaderCache, cachepath);
+}
+#endif
+
 /* imap_parse_path: given an IMAP mailbox name, return host, port
  *   and a path IMAP servers will recognise.
  * mx.mbox is malloc'd, caller must free it */