]> granicus.if.org Git - neomutt/commitdiff
This patch includes (1) a rewrite of hash_delete_hash, and (2) some
authorThomas Roessler <roessler@does-not-exist.org>
Sun, 24 Jul 2005 15:46:26 +0000 (15:46 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Sun, 24 Jul 2005 15:46:26 +0000 (15:46 +0000)
changes to the IMAP code that Thomas Glanzmann made during an
attempt to squash some segmentation fault in May.  There is no
guarantee that this patch doesn't break things.  If it does, please
complain to mutt-dev.

hash.c
imap/message.c
imap/util.c

diff --git a/hash.c b/hash.c
index 01eaad70fd3bbfed71dbc6f7f95985f811c5b30e..a4c72916ef5c27bcb48ddec184fe97dd918ff1f2 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -117,18 +117,22 @@ void hash_delete_hash (HASH * table, int hash, const char *key, const void *data
   struct hash_elem *ptr = table->table[hash];
   struct hash_elem **last = &table->table[hash];
 
-  for (; ptr; last = &ptr->next, ptr = ptr->next)
+  while (ptr) 
   {
-    /* if `data' is given, look for a matching ->data member.  this is
-     * required for the case where we have multiple entries with the same
-     * key
-     */
-    if ((data == ptr->data) || (!data && mutt_strcmp (ptr->key, key) == 0))
+    if ((data == ptr->data || !data)
+       && mutt_strcmp (ptr->key, key) == 0)
     {
       *last = ptr->next;
-      if (destroy) destroy (ptr->data);
+      if (destroy)
+       destroy (ptr->data);
       FREE (&ptr);
-      return;
+      
+      ptr = *last;
+    }
+    else
+    {
+      last = &ptr->next;
+      ptr = ptr->next;
     }
   }
 }
index 1cc1181a3f38ddd5026af1749f4c6a0eefa43309..990f156c986a4bbbeae321973c75226528f1a2e2 100644 (file)
@@ -314,7 +314,10 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
   fclose(fp);
 
   if (ctx->msgcount > oldmsgcount)
+  {
+    mx_alloc_memory(ctx);
     mx_update_context (ctx, ctx->msgcount - oldmsgcount);
+  }
 
   return msgend;
 }
@@ -469,6 +472,8 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
     hash_delete (ctx->id_hash, h->env->message_id, h, NULL);
   if (ctx->subj_hash && h->env->real_subj)
     hash_delete (ctx->subj_hash, h->env->real_subj, h, NULL);
+  if (ctx->thread_hash && h->env->message_id)
+    hash_delete (ctx->thread_hash, h->env->message_id, NULL, NULL);
   mutt_free_envelope (&h->env);
   h->env = mutt_read_rfc822_header (msg->fp, h, 0, 0);
   if (ctx->id_hash && h->env->message_id)
index 5062786b3c51b2e25d6b9f35d1a1f09f1f35867e..a83bcc2801cc73d779c5a9b8fe3403442ea70cfd 100644 (file)
@@ -138,11 +138,11 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
     {
       *c = '\0';
       strfcpy (mx->account.user, tmp, sizeof (mx->account.user));
-      strfcpy (tmp, c+1, sizeof (tmp));
+      c++;
       mx->account.flags |= M_ACCT_USER;
     }
   
-    if ((n = sscanf (tmp, "%127[^:/]%127s", mx->account.host, tmp)) < 1)
+    if ((n = sscanf (c, "%127[^:/]%127s", mx->account.host, c)) < 1)
     {
       dprint (1, (debugfile, "imap_parse_path: NULL host in %s\n", path));
       FREE (&mx->mbox);
@@ -150,11 +150,11 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
     }
   
     if (n > 1) {
-      if (sscanf (tmp, ":%hu%127s", &(mx->account.port), tmp) >= 1)
+      if (sscanf (c, ":%hu%127s", &(mx->account.port), c) >= 1)
        mx->account.flags |= M_ACCT_PORT;
-      if (sscanf (tmp, "/%s", tmp) == 1)
+      if (sscanf (c, "/%s", c) == 1)
       {
-       if (!ascii_strncmp (tmp, "ssl", 3))
+       if (!ascii_strncmp (c, "ssl", 3))
          mx->account.flags |= M_ACCT_SSL;
        else
        {