if (rfc1524_mailcap_lookup (a, type, NULL, MUTT_PRINT))
{
- rfc1524_entry *entry;
+ rfc1524_entry *entry = NULL;
int piped = FALSE;
dprint (2, (debugfile, "Using mailcap...\n"));
if (safe_symlink (a->filename, mutt_b2s (newfile)) == -1)
{
if (mutt_yesorno (_("Can't match nametemplate, continue?"), MUTT_YES) != MUTT_YES)
- {
- rfc1524_free_entry (&entry);
- goto out;
- }
+ goto mailcap_cleanup;
mutt_buffer_strcpy (newfile, a->filename);
}
else
}
/* in recv mode, save file to newfile first */
else
- mutt_save_attachment (fp, a, mutt_b2s (newfile), 0, NULL);
+ {
+ if (mutt_save_attachment (fp, a, mutt_b2s (newfile), 0, NULL) == -1)
+ goto mailcap_cleanup;
+ }
mutt_buffer_strcpy (command, entry->printcommand);
piped = mutt_rfc1524_expand_command (a, mutt_b2s (newfile), type, command);
if ((ifp = fopen (mutt_b2s (newfile), "r")) == NULL)
{
mutt_perror ("fopen");
- rfc1524_free_entry (&entry);
- goto out;
+ goto mailcap_cleanup;
}
if ((thepid = mutt_create_filter (mutt_b2s (command), &fpout, NULL, NULL)) < 0)
{
mutt_perror _("Can't create filter");
- rfc1524_free_entry (&entry);
safe_fclose (&ifp);
- goto out;
+ goto mailcap_cleanup;
}
mutt_copy_stream (ifp, fpout);
safe_fclose (&fpout);
mutt_any_key_to_continue (NULL);
}
+ rc = 1;
+
+ mailcap_cleanup:
if (fp)
mutt_unlink (mutt_b2s (newfile));
else if (unlink_newfile)
unlink(mutt_b2s (newfile));
rfc1524_free_entry (&entry);
- rc = 1;
goto out;
}
if ((ifp = fopen (mutt_b2s (newfile), "r")) == NULL)
{
mutt_perror ("fopen");
- goto bail0;
+ goto decode_cleanup;
}
dprint (2, (debugfile, "successfully opened %s read-only\n", mutt_b2s (newfile)));
if ((thepid = mutt_create_filter (NONULL(PrintCmd), &fpout, NULL, NULL)) < 0)
{
mutt_perror _("Can't create filter");
- goto bail0;
+ goto decode_cleanup;
}
dprint (2, (debugfile, "Filter created.\n"));
mutt_any_key_to_continue (NULL);
rc = 1;
}
- bail0:
+ decode_cleanup:
safe_fclose (&ifp);
safe_fclose (&fpout);
mutt_unlink (mutt_b2s (newfile));