From 45e2c9ad60cd3c42dab9aa920bc049549eba4509 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Sun, 24 Jul 2005 15:46:26 +0000 Subject: [PATCH] This patch includes (1) a rewrite of hash_delete_hash, and (2) some 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 | 20 ++++++++++++-------- imap/message.c | 5 +++++ imap/util.c | 10 +++++----- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/hash.c b/hash.c index 01eaad70f..a4c72916e 100644 --- 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; } } } diff --git a/imap/message.c b/imap/message.c index 1cc1181a3..990f156c9 100644 --- a/imap/message.c +++ b/imap/message.c @@ -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) diff --git a/imap/util.c b/imap/util.c index 5062786b3..a83bcc280 100644 --- a/imap/util.c +++ b/imap/util.c @@ -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 { -- 2.40.0