File mutt-colon.patch of Package mutt.23793
From 4a2becbdb4422aaffe3ce314991b9d670b7adf17 Mon Sep 17 00:00:00 2001
From: Kevin McCarthy <kevin@8t8.us>
Date: Sun, 17 Jan 2021 10:40:37 -0800
Subject: [PATCH] Fix memory leak parsing group addresses without a display
name.
When there was a group address terminator with no previous
addresses (including the group display-name), an address would be
allocated but not attached to the address list.
Change this to only allocate when last exists.
It would be more correct to not allocate at all unless we are inside a
group list, but I will address that in a separate commit to master.
From 939b02b33ae29bc0d642570c1dcfd4b339037d19 Mon Sep 17 00:00:00 2001
From: Kevin McCarthy <kevin@8t8.us>
Date: Sun, 17 Jan 2021 10:53:19 -0800
Subject: [PATCH] Don't allocate a group terminator unless we are in a
group-list.
This will reduce memory allocation for garbage/spam address lists.
It also makes no sense to store a terminator when there wasn't a
display-name indicating the start of a group.
From d4305208955c5cdd9fe96dfa61e7c1e14e176a14 Mon Sep 17 00:00:00 2001
From: Kevin McCarthy <kevin@8t8.us>
Date: Sun, 17 Jan 2021 11:05:36 -0800
Subject: [PATCH] Add group terminator if it is left off.
If there is no terminating ";" add one to the list, to make the text
re-rendering correct.
---
rfc822.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
--- rfc822.c
+++ rfc822.c 2021-01-21 14:49:11.766665564 +0000
@@ -372,7 +372,7 @@ add_addrspec (ADDRESS **top, ADDRESS **l
ADDRESS *rfc822_parse_adrlist (ADDRESS *top, const char *s)
{
- int ws_pending, nl;
+ int ws_pending, nl, in_group = 0;
#ifdef EXACT_ADDRESS
const char *begin;
#endif
@@ -449,6 +449,7 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *
terminate_buffer (phrase, phraselen);
cur->mailbox = safe_strdup (phrase);
cur->group = 1;
+ in_group = 1;
if (last)
last->next = cur;
@@ -485,12 +486,12 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *
#endif
/* add group terminator */
- cur = rfc822_new_address ();
- if (last)
+ if (last && in_group)
{
- last->next = cur;
- last = cur;
+ last->next = rfc822_new_address ();
+ last = last->next;
}
+ in_group = 0;
phraselen = 0;
commentlen = 0;
@@ -553,6 +554,10 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *
last->val = mutt_substrdup (begin, s - nl < begin ? begin : s - nl);
#endif
+ /* add group terminator, if it was left off */
+ if (last && in_group)
+ last->next = rfc822_new_address ();
+
return top;
}