]> git.wh0rd.org Git - nano.git/commitdiff
Avoiding a call of copy_file() with a null pointer.
authorBenno Schulenberg <bensberg@justemail.net>
Tue, 11 Aug 2015 17:27:30 +0000 (17:27 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Tue, 11 Aug 2015 17:27:30 +0000 (17:27 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5352 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/files.c

index 915b5273fbb7c368fd29fa733e27cb2a39417a7d..53fca6fee598092d847aeaf45d95d6c6fcfdbbc5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-08-11  Benno Schulenberg  <bensberg@justemail.net>
+       * src/files.c (write_file): Avoid calling copy_file() with a null
+       pointer.  Found with cppcheck.
+
 2015-08-09  Benno Schulenberg  <bensberg@justemail.net>
        * src/global.c, src/help.c (help_init), src/nano.c (do_toggle, main),
        src/winio.c (display_string, statusbar): Allow toggling the display
index 30721d2207c28fb7e11b73fcaeacd1093ab81aff..5f95ae32d9ce65aa3b65b1771a57d919d114ffdb 100644 (file)
@@ -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);