From 0e76930c3b951a82f780a33beff48a6b1f7dba2c Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Tue, 26 Mar 2002 12:58:12 +0000 Subject: [PATCH] files.c:read_file() - Reverse tests to stop segfault on editing a new file of 0 lines (David Benbennick) git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_1_0_branch/nano@1146 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ files.c | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e1b05244..8301e5fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ CVS code - - Plug some memory leaks (Steven Kneizys). read_file() - Abort if we read a file of 0 lines (num_lines == 0), fixes BUG #70. + - Reverse tests to stop segfault on editing a new file of 0 lines + (David Benbennick). - nano.c: do_int_speller() - Fix zombie processes and spelling buffer issues (Rocco Corsi) diff --git a/files.c b/files.c index 722deaca..f1a8cfb4 100644 --- a/files.c +++ b/files.c @@ -181,13 +181,6 @@ int read_file(int fd, char *filename) buf[0] = 0; } - /* Did we try to insert a file of 0 bytes? */ - if (num_lines == 0) - { - statusbar(_("Read %d lines"), 0); - return 1; - } - /* Did we even GET a file if we don't already have one? */ if (totsize == 0 || fileptr == NULL) { new_file(); @@ -195,6 +188,13 @@ int read_file(int fd, char *filename) return 1; } + /* Did we try to insert a file of 0 bytes? */ + if (num_lines == 0) + { + statusbar(_("Read %d lines"), 0); + return 1; + } + if (current != NULL) { fileptr->next = current; current->prev = fileptr; -- 2.39.5