- m_strcpy(tmpfile, sizeof(tmpfile), basename(filename));
- mutt_adv_mktemp ((const char*) dirname (buf), tmpfile, sizeof (tmpfile));
- debug_print (1, ("Opening %s\n", tmpfile));
- if (!(ofp = fopen (tmpfile, "w"))) {
- fclose (ifp);
- mutt_error (_("Unable to open %s for writing"), tmpfile);
+ ofp = m_tempfile(tmpf, sizeof(tmpf), dirname(buf), filename);
+ if (!ofp) {
+ m_fclose(&ifp);
+ mutt_error (_("Unable to open %s for writing"), tmpf);