]> granicus.if.org Git - mutt/commitdiff
Convert attach_forward_msgs() to use buffer pool.
authorKevin McCarthy <kevin@8t8.us>
Wed, 23 Oct 2019 07:36:59 +0000 (15:36 +0800)
committerKevin McCarthy <kevin@8t8.us>
Wed, 23 Oct 2019 07:36:59 +0000 (15:36 +0800)
recvcmd.c

index bdbd1902c533db9a3c5d3e9dcd3ea37538243945..c880d53e4a91337633247cf2cc44718ef43d3ade 100644 (file)
--- 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,