From 3a7c0bee6bbc808fe56b8482c06c297995828722 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Mon, 18 Dec 2000 01:09:07 +0000 Subject: [PATCH] Fix segfault when read_file encounters an error opening the file git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@410 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 3 +++ files.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 41bb6ff6..68de2c2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,9 @@ General - Fix magic line not getting created when (you guessed it) uncutting marked text at filebot (Ryan Krebs). - files.c: + read_file() + - If we encounter an error and insert is not set, run new_file(). + (bug discovered by Ben Roberts). write_file() - Change open call flags, basically copy joe's way of doing it so a more recent version will actually be included in (un)stable. diff --git a/files.c b/files.c index 18f65211..c39a482a 100644 --- a/files.c +++ b/files.c @@ -227,6 +227,8 @@ int open_file(char *filename, int insert, int quiet) } else if ((fd = open(filename, O_RDONLY)) == -1) { if (!quiet) statusbar("%s: %s", strerror(errno), filename); + if (!insert) + new_file(); return -1; } else { /* File is A-OK */ if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) || -- 2.39.5