commit 3a7c0bee6bbc808fe56b8482c06c297995828722
parent 1a6e904583e14276b97a76a1e6978292a44f6c5d
Author: Chris Allegretta <chrisa@asty.org>
Date: Mon, 18 Dec 2000 01:09:07 +0000
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
Diffstat:
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git 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
@@ -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) ||