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-d3aeb78583b8master
parent
1a6e904583
commit
3a7c0bee6b
|
@ -14,6 +14,9 @@ General
|
||||||
- Fix magic line not getting created when (you guessed it)
|
- Fix magic line not getting created when (you guessed it)
|
||||||
uncutting marked text at filebot (Ryan Krebs).
|
uncutting marked text at filebot (Ryan Krebs).
|
||||||
- files.c:
|
- files.c:
|
||||||
|
read_file()
|
||||||
|
- If we encounter an error and insert is not set, run new_file().
|
||||||
|
(bug discovered by Ben Roberts).
|
||||||
write_file()
|
write_file()
|
||||||
- Change open call flags, basically copy joe's way of doing it so
|
- Change open call flags, basically copy joe's way of doing it so
|
||||||
a more recent version will actually be included in (un)stable.
|
a more recent version will actually be included in (un)stable.
|
||||||
|
|
2
files.c
2
files.c
|
@ -227,6 +227,8 @@ int open_file(char *filename, int insert, int quiet)
|
||||||
} else if ((fd = open(filename, O_RDONLY)) == -1) {
|
} else if ((fd = open(filename, O_RDONLY)) == -1) {
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
statusbar("%s: %s", strerror(errno), filename);
|
statusbar("%s: %s", strerror(errno), filename);
|
||||||
|
if (!insert)
|
||||||
|
new_file();
|
||||||
return -1;
|
return -1;
|
||||||
} else { /* File is A-OK */
|
} else { /* File is A-OK */
|
||||||
if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
|
if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
|
||||||
|
|
Loading…
Reference in New Issue