mirror of
git://git.sv.gnu.org/nano.git
synced 2025-02-12 19:34:18 +03:00
tweaks: don't leave an orphaned temporary file behind when writing fails
This commit is contained in:
parent
803ea0d7a0
commit
3def429290
10
src/text.c
10
src/text.c
@ -2528,6 +2528,7 @@ void do_spell(void)
|
||||
|
||||
if (!okay) {
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
unlink(temp_name);
|
||||
free(temp_name);
|
||||
return;
|
||||
}
|
||||
@ -2924,13 +2925,10 @@ void do_formatter(void)
|
||||
if (temp_name != NULL)
|
||||
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
|
||||
|
||||
if (!okay) {
|
||||
if (!okay)
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
free(temp_name);
|
||||
return;
|
||||
}
|
||||
|
||||
treat(temp_name, openfile->syntax->formatter, FALSE);
|
||||
else
|
||||
treat(temp_name, openfile->syntax->formatter, FALSE);
|
||||
|
||||
unlink(temp_name);
|
||||
free(temp_name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user