summaryrefslogtreecommitdiffstats
path: root/copy.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2018-12-28 15:43:51 -0800
committerKevin McCarthy <kevin@8t8.us>2018-12-28 15:43:51 -0800
commit63f05d9682a7612e3022aa325a9b64b670f4c341 (patch)
tree962d93e44740dba905970b7fbeb1d86f54e9f47d /copy.c
parent8bb109563f0147fe53b681d5e887a634bdb3a1d1 (diff)
Make a copy of x_label before encoding it for updates.
This isn't actually a bug. Context->label_hash strdups the keys, so we are safe from dangling references. However, the subj_hash uses direct references, so to keep things consistent and safe, make a copy and encode that.
Diffstat (limited to 'copy.c')
-rw-r--r--copy.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/copy.c b/copy.c
index 1a971558..58599731 100644
--- a/copy.c
+++ b/copy.c
@@ -351,6 +351,7 @@ int
mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
{
char buffer[SHORT_STRING];
+ char *temp_hdr = NULL;
if (h->env)
flags |= (h->env->irt_changed ? CH_UPDATE_IRT : 0)
@@ -424,15 +425,22 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
if ((flags & CH_UPDATE_LABEL) && h->env->x_label)
{
h->xlabel_changed = 0;
+ temp_hdr = h->env->x_label;
+ /* env->x_label isn't currently stored with direct references
+ * elsewhere. Context->label_hash strdups the keys. But to be
+ * safe, encode a copy */
if (!(flags & CH_DECODE))
- rfc2047_encode_string (&h->env->x_label);
- if (mutt_write_one_header (out, "X-Label", h->env->x_label,
+ {
+ temp_hdr = safe_strdup (temp_hdr);
+ rfc2047_encode_string (&temp_hdr);
+ }
+ if (mutt_write_one_header (out, "X-Label", temp_hdr,
flags & CH_PREFIX ? prefix : 0,
mutt_window_wrap_cols (MuttIndexWindow, Wrap),
flags) == -1)
return -1;
if (!(flags & CH_DECODE))
- rfc2047_decode (&h->env->x_label);
+ FREE (&temp_hdr);
}
if ((flags & CH_NONEWLINE) == 0)