diff --git a/ChangeLog b/ChangeLog index 915b5273..53fca6fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-08-11 Benno Schulenberg + * src/files.c (write_file): Avoid calling copy_file() with a null + pointer. Found with cppcheck. + 2015-08-09 Benno Schulenberg * src/global.c, src/help.c (help_init), src/nano.c (do_toggle, main), src/winio.c (display_string, statusbar): Allow toggling the display diff --git a/src/files.c b/src/files.c index 30721d22..5f95ae32 100644 --- a/src/files.c +++ b/src/files.c @@ -2007,7 +2007,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type } } - if (copy_file(f_source, f) != 0) { + if (f_source == NULL || copy_file(f_source, f) != 0) { statusbar(_("Error writing %s: %s"), tempname, strerror(errno)); unlink(tempname);