]> granicus.if.org Git - neomutt/commitdiff
More postpone cleanup
authorKevin McCarthy <kevin@8t8.us>
Thu, 20 Dec 2018 02:36:19 +0000 (18:36 -0800)
committerRichard Russon <rich@flatcap.org>
Mon, 7 Jan 2019 15:09:41 +0000 (15:09 +0000)
Provide an error message if $postponed is not set.

Make sure the clear content is freed for encrypted messages.

If the write_fcc() fails, make sure to restore the clear content.

Co-authored-by: Richard Russon <rich@flatcap.org>
send.c

diff --git a/send.c b/send.c
index 0f978d039306ebc0802a4d5b2ac1f7469557b904..2169830a2faf411688426185be0b8dd58960c51b 100644 (file)
--- a/send.c
+++ b/send.c
@@ -1648,9 +1648,13 @@ static int postpone_message(struct Email *msg, struct Email *cur, char *fcc, int
   char *pgpkeylist = NULL;
   char *encrypt_as = NULL;
   int is_signed;
+  struct Body *clear_content = NULL;
 
-  if (!Postponed)
+  if (!(Postponed && *Postponed))
+  {
+    mutt_error(_("Can not postpone.  $postponed is unset"));
     return -1;
+  }
 
   if (msg->content->next)
     msg->content = mutt_make_multipart(msg->content);
@@ -1673,6 +1677,7 @@ static int postpone_message(struct Email *msg, struct Email *cur, char *fcc, int
         msg->security &= ~SIGN;
 
       pgpkeylist = mutt_str_strdup(encrypt_as);
+      clear_content = msg->content;
       if (mutt_protect(msg, pgpkeylist) == -1)
       {
         if (is_signed)
@@ -1704,13 +1709,22 @@ static int postpone_message(struct Email *msg, struct Email *cur, char *fcc, int
                      (cur && (flags & SEND_REPLY)) ? cur->env->message_id : NULL,
                      true, fcc, NULL) < 0)
   {
+    if (clear_content)
+    {
+      mutt_body_free(&msg->content);
+      msg->content = clear_content;
+    }
     msg->content = mutt_remove_multipart(msg->content);
     decode_descriptions(msg->content);
     mutt_unprepare_envelope(msg->env);
     return -1;
   }
+
   mutt_update_num_postponed();
 
+  if (clear_content)
+    mutt_body_free(&clear_content);
+
   return 0;
 }