From: Kevin McCarthy Date: Thu, 20 Dec 2018 02:36:19 +0000 (-0800) Subject: More postpone cleanup X-Git-Tag: 2019-10-25~396^2~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3279ca8ed8e896fa01fcfc05f9bf1de5836b630d;p=neomutt More postpone cleanup 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 --- diff --git a/send.c b/send.c index 0f978d039..2169830a2 100644 --- 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; }