1
1

tweaks: don't leave an orphaned temporary file behind when writing fails

Этот коммит содержится в:
Benno Schulenberg 2022-03-27 12:34:32 +02:00
родитель 803ea0d7a0
Коммит 3def429290

Просмотреть файл

@ -2528,6 +2528,7 @@ void do_spell(void)
if (!okay) { if (!okay) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno)); statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
unlink(temp_name);
free(temp_name); free(temp_name);
return; return;
} }
@ -2924,13 +2925,10 @@ void do_formatter(void)
if (temp_name != NULL) if (temp_name != NULL)
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES); okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
if (!okay) { if (!okay)
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno)); statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
free(temp_name); else
return; treat(temp_name, openfile->syntax->formatter, FALSE);
}
treat(temp_name, openfile->syntax->formatter, FALSE);
unlink(temp_name); unlink(temp_name);
free(temp_name); free(temp_name);