From: Kevin McCarthy Date: Wed, 23 Oct 2019 07:36:59 +0000 (+0800) Subject: Convert attach_forward_msgs() to use buffer pool. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8d12d9005ed83308272cc0b54fc0c5ccc743cda9;p=mutt Convert attach_forward_msgs() to use buffer pool. --- diff --git a/recvcmd.c b/recvcmd.c index bdbd1902..c880d53e 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -587,12 +587,12 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr, ATTACH_CONTEXT *actx, BODY * cur) { HEADER *curhdr = NULL; - HEADER *tmphdr; + HEADER *tmphdr = NULL; short i; int rc; BODY **last; - char tmpbody[_POSIX_PATH_MAX]; + BUFFER *tmpbody = NULL; FILE *tmpfp = NULL; int cmflags = 0; @@ -615,7 +615,7 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr, mutt_make_forward_subject (tmphdr->env, Context, curhdr); - tmpbody[0] = '\0'; + tmpbody = mutt_buffer_pool_get (); if ((rc = query_quadoption (OPT_MIMEFWD, _("Forward MIME encapsulated?"))) == MUTT_NO) @@ -623,12 +623,11 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr, /* no MIME encapsulation */ - mutt_mktemp (tmpbody, sizeof (tmpbody)); - if (!(tmpfp = safe_fopen (tmpbody, "w"))) + mutt_buffer_mktemp (tmpbody); + if (!(tmpfp = safe_fopen (mutt_b2s (tmpbody), "w"))) { - mutt_error (_("Can't create %s."), tmpbody); - mutt_free_header (&tmphdr); - return; + mutt_error (_("Can't create %s."), mutt_b2s (tmpbody)); + goto cleanup; } if (option (OPTFORWQUOTE)) @@ -689,9 +688,14 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr, else mutt_free_header (&tmphdr); - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL, + ci_send_message (0, tmphdr, + mutt_buffer_len (tmpbody) ? mutt_b2s (tmpbody) : NULL, NULL, curhdr); + tmphdr = NULL; /* ci_send_message frees this */ +cleanup: + mutt_free_header (&tmphdr); + mutt_buffer_pool_release (&tmpbody); } void mutt_attach_forward (FILE * fp, HEADER * hdr,