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
master
Chris Allegretta 2000-12-18 01:09:07 +00:00
parent 1a6e904583
commit 3a7c0bee6b
2 changed files with 5 additions and 0 deletions

View File

@ -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.

View File

@ -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) ||