summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2019-10-23 15:36:59 +0800
committerKevin McCarthy <kevin@8t8.us>2019-10-23 15:36:59 +0800
commit8d12d9005ed83308272cc0b54fc0c5ccc743cda9 (patch)
tree3967db114002ae424f2dd1e70a7379a71dfd9e61
parent0b59dc759c3d9d59fd9423500cf775a76622b634 (diff)
Convert attach_forward_msgs() to use buffer pool.
-rw-r--r--recvcmd.c22
1 files changed, 13 insertions, 9 deletions
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,