In the compose menu, mutt_view_attachment() calls
mutt_decode_save_attachment(), which calls mutt_parse_parts().

This function took care to save the m->hdr and m->parts but only
restored for the case that m->parts previously existed.  As noted in
the previous commit, mutt_message_to_7bit() removes parts and keeps
hdr.  So the restore was not taking place, leading to a memory leak in
this case.

Change the restore to check for either parts or hdr.
---
 attach.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/attach.c b/attach.c
index 59fe1a26..b9880f11 100644
--- a/attach.c
+++ b/attach.c
@@ -930,7 +930,7 @@ int mutt_decode_save_attachment(FILE *fp, BODY *m, const 
char *path,
   {
     m->length = 0;
     m->encoding = saved_encoding;
-    if (saved_parts)
+    if (saved_parts || saved_hdr)
     {
       mutt_free_header(&m->hdr);
       m->parts = saved_parts;
-- 
2.55.0

Reply via email to