2015-08-11 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (write_file): Avoid calling copy_file() with a null
pointer. Found with cppcheck.
+ * src/files.c (write_file): A failure to delete the temporary file
+ does not mean that it wasn't copied properly.
2015-08-09 Benno Schulenberg <bensberg@justemail.net>
* src/global.c, src/help.c (help_init), src/nano.c (do_toggle, main),
FILE *f = NULL;
/* The actual file, realname, we are writing to. */
char *tempname = NULL;
- /* The temp file name we write to on prepend. */
+ /* The name of the temporary file we write to on prepend. */
assert(name != NULL);
goto cleanup_and_exit;
}
- if (copy_file(f_source, f) == -1 || unlink(tempname) == -1) {
+ if (copy_file(f_source, f) == -1) {
statusbar(_("Error writing %s: %s"), realname,
strerror(errno));
goto cleanup_and_exit;
}
+
+ unlink(tempname);
} else if (fclose(f) != 0) {
statusbar(_("Error writing %s: %s"), realname,
strerror(errno));