From: Chris Allegretta Date: Sun, 15 Nov 2015 06:47:11 +0000 (+0000) Subject: Backport r5352 from trunk. X-Git-Tag: v2.4.3~10 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=1e54399e0cf282305eb32de4d8519cc0a4e66ac6;p=nano.git Backport r5352 from trunk. git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_2_4_branch@5414 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index cc98a421..4bbc4130 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-08 Benno Schulenberg * src/winio.c (display_string): For some reason the reallocation done by null_at() messes things up. So put in the null byte "manually". diff --git a/src/files.c b/src/files.c index 5229de68..85bb006a 100644 --- a/src/files.c +++ b/src/files.c @@ -2016,7 +2016,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);