From 1ac617f9d4f93bbbb9cc7e19b767e21686f7a01d Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Tue, 4 Oct 2016 11:13:24 -0700 Subject: [PATCH] Preserve forwarded attachment names in d_filename. When forwarding an attachment with an non-ascii name, mutt_copy_body() mangles the filename when calling mutt_adv_mktemp. Preserve the original attachment filename in d_filename. Remove the double copy of b->filename, which is a memory leak. --- muttlib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/muttlib.c b/muttlib.c index b5bf1c1cb..560c0abad 100644 --- a/muttlib.c +++ b/muttlib.c @@ -151,8 +151,11 @@ int mutt_copy_body (FILE *fp, BODY **tgt, BODY *src) b->xtype = safe_strdup (b->xtype); b->subtype = safe_strdup (b->subtype); b->form_name = safe_strdup (b->form_name); - b->filename = safe_strdup (b->filename); b->d_filename = safe_strdup (b->d_filename); + /* mutt_adv_mktemp() will mangle the filename in tmp, + * so preserve it in d_filename */ + if (!b->d_filename && use_disp) + b->d_filename = safe_strdup (src->filename); b->description = safe_strdup (b->description); /* -- 2.40.0