short i;
STATE st;
- char tmpbody[_POSIX_PATH_MAX];
- FILE *tmpfp;
+ BUFFER *tmpbody = NULL;
+ FILE *tmpfp = NULL;
char prefix[SHORT_STRING];
int rc;
if (attach_reply_envelope_defaults (tmphdr->env, actx,
parent_hdr ? parent_hdr : (cur ? cur->hdr : NULL), flags) == -1)
- {
- mutt_free_header (&tmphdr);
- return;
- }
+ goto cleanup;
- mutt_mktemp (tmpbody, sizeof (tmpbody));
- if ((tmpfp = safe_fopen (tmpbody, "w")) == NULL)
+ tmpbody = mutt_buffer_pool_get ();
+ mutt_buffer_mktemp (tmpbody);
+ if ((tmpfp = safe_fopen (mutt_b2s (tmpbody), "w")) == NULL)
{
- mutt_error (_("Can't create %s."), tmpbody);
- mutt_free_header (&tmphdr);
- return;
+ mutt_error (_("Can't create %s."), mutt_b2s (tmpbody));
+ goto cleanup;
}
if (!parent_hdr)
if (mime_reply_any && !cur &&
copy_problematic_attachments (&tmphdr->content, actx, 0) == NULL)
{
- mutt_free_header (&tmphdr);
- safe_fclose (&tmpfp);
- return;
+ goto cleanup;
}
}
safe_fclose (&tmpfp);
- if (ci_send_message (flags, tmphdr, tmpbody, NULL,
+ if (ci_send_message (flags, tmphdr, mutt_b2s (tmpbody), NULL,
parent_hdr ? parent_hdr : (cur ? cur->hdr : NULL)) == 0)
mutt_set_flag (Context, hdr, MUTT_REPLIED, 1);
+
+ tmphdr = NULL; /* ci_send_message frees this */
+
+cleanup:
+ if (tmpfp)
+ {
+ safe_fclose (&tmpfp);
+ mutt_unlink (mutt_b2s (tmpbody));
+ }
+ mutt_buffer_pool_release (&tmpbody);
+ mutt_free_header (&tmphdr);
}