if ((in = safe_fopen (hdr->content->filename, "r")) == NULL)
return;
- mutt_mktemp (tmpf);
- if ((out = safe_fopen (tmpf, "w+")) == NULL) {
- fclose (in);
+
+ out = m_tempfile(tmpf, sizeof(tmpf), NONULL(Tempdir), NULL);
+ if (!out) {
+ m_fclose(&in);
return;
}
- while (fgets (buf, sizeof (buf), in)) {
+ while (fgets(buf, sizeof (buf), in)) {
if (m_strncmp("From ", buf, 4) == 0 || buf[0] == ' ') {
fputc (' ', out);
}
fputs (buf, out);
}
- fclose (in);
- fclose (out);
+ m_fclose(&in);
+ m_fclose(&out);
mutt_set_mtime (hdr->content->filename, tmpf);
unlink (hdr->content->filename);
m_strreplace(&hdr->content->filename, tmpf);