From b2f5bb2df3a5f91bdc2bf888fefa4e502923609f Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Wed, 23 Oct 2019 15:04:49 +0800 Subject: [PATCH] Convert attach_forward_bodies to use buffer pool Upstream-commit: https://gitlab.com/muttmua/mutt/commit/0b59dc759c3d9d59fd9423500cf775a76622b634 Co-authored-by: Richard Russon --- recvcmd.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/recvcmd.c b/recvcmd.c index 87e5e6648..ff08fdd39 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -463,9 +463,9 @@ static void attach_forward_bodies(FILE *fp, struct Email *e, struct AttachCtx *a bool mime_fwd_any = true; struct Email *e_parent = NULL; FILE *fp_parent = NULL; - char tmpbody[PATH_MAX]; char prefix[256]; enum QuadOption ans = MUTT_ABORT; + struct Buffer *tmpbody = NULL; /* First, find the parent message. * Note: This could be made an option by just @@ -486,13 +486,14 @@ static void attach_forward_bodies(FILE *fp, struct Email *e, struct AttachCtx *a e_tmp->env = mutt_env_new(); mutt_make_forward_subject(e_tmp->env, Context->mailbox, e_parent); - mutt_mktemp(tmpbody, sizeof(tmpbody)); - FILE *fp_tmp = mutt_file_fopen(tmpbody, "w"); + tmpbody = mutt_buffer_pool_get(); + mutt_buffer_mktemp(tmpbody); + FILE *fp_tmp = mutt_file_fopen(mutt_b2s(tmpbody), "w"); if (!fp_tmp) { - mutt_error(_("Can't open temporary file %s"), tmpbody); + mutt_error(_("Can't open temporary file %s"), mutt_b2s(tmpbody)); email_free(&e_tmp); - return; + goto bail; } mutt_forward_intro(Context->mailbox, e_parent, fp_tmp); @@ -598,17 +599,18 @@ static void attach_forward_bodies(FILE *fp, struct Email *e, struct AttachCtx *a /* now that we have the template, send it. */ struct EmailList el = STAILQ_HEAD_INITIALIZER(el); el_add_email(&el, e_parent); - ci_send_message(SEND_NO_FLAGS, e_tmp, tmpbody, NULL, &el); + ci_send_message(SEND_NO_FLAGS, e_tmp, mutt_b2s(tmpbody), NULL, &el); emaillist_clear(&el); + mutt_buffer_pool_release(&tmpbody); return; bail: - if (fp_tmp) { mutt_file_fclose(&fp_tmp); - mutt_file_unlink(tmpbody); + mutt_file_unlink(mutt_b2s(tmpbody)); } + mutt_buffer_pool_release(&tmpbody); email_free(&e_tmp); } -- 2.40.0