]> granicus.if.org Git - mutt/commitdiff
Don't evaluate hcache unless uidnext > 0. This shouldn't happen, but it
authorBrendan Cully <brendan@kublai.com>
Fri, 23 Dec 2005 18:20:02 +0000 (18:20 +0000)
committerBrendan Cully <brendan@kublai.com>
Fri, 23 Dec 2005 18:20:02 +0000 (18:20 +0000)
was reported to. I probably have to be a lot more careful about the
uid datatypes but I'm too lazy to clean up right now.

imap/imap_private.h
imap/message.c

index 705180f19c1c7d7592a693e553fab0e963b37dcd..82d9bfc5b1edbefc9a5a0b28ef8543b4f9ee0e67 100644 (file)
@@ -220,8 +220,8 @@ typedef struct
   unsigned char rights[(RIGHTSMAX + 7)/8];
   unsigned int newMailCount;
   IMAP_CACHE cache[IMAP_CACHE_LEN];
-  uint32_t uid_validity;
-  uint32_t uidnext;
+  unsigned int uid_validity;
+  unsigned int uidnext;
   
   /* all folder flags - system flags AND keywords */
   LIST *flags;
index a43ad5b29c96c072911193b947dba3c930c6a622..681b8feb6587c60293a37ea4998e4fafc498f269 100644 (file)
@@ -72,8 +72,8 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
 
 #if USE_HCACHE
   void *hc = NULL;
-  uint32_t *uid_validity = NULL;
-  uint32_t *uidnext = NULL;
+  unsigned int *uid_validity = NULL;
+  unsigned int *uidnext = NULL;
   int evalhc = 0;
   char uid_buf[64];
 #endif /* USE_HCACHE */
@@ -124,14 +124,15 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
   {
     uid_validity = mutt_hcache_fetch_raw (hc, "/UIDVALIDITY", imap_hcache_keylen);
     uidnext = mutt_hcache_fetch_raw (hc, "/UIDNEXT", imap_hcache_keylen);
-    if (uid_validity && uidnext && *uid_validity == idata->uid_validity)
+    if (uid_validity && uidnext && *uid_validity == idata->uid_validity
+        && *uidnext > 0)
       evalhc = 1;
     FREE (&uid_validity);
   }
   if (evalhc)
   {
     snprintf (buf, sizeof (buf),
-      "UID FETCH %d:%d (UID FLAGS)", 1, *uidnext - 1);
+      "UID FETCH 1:%u (UID FLAGS)", *uidnext - 1);
     FREE (&uidnext);
   
     imap_cmd_start (idata, buf);
@@ -158,7 +159,7 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
           break;
 
         sprintf(uid_buf, "/%u", h.data->uid); /* XXX --tg 21:41 04-07-11 */
-        uid_validity = (uint32_t*)mutt_hcache_fetch (hc, uid_buf, &imap_hcache_keylen);
+        uid_validity = (unsigned int*)mutt_hcache_fetch (hc, uid_buf, &imap_hcache_keylen);
 
         if (uid_validity != NULL && *uid_validity == idata->uid_validity)
         {