From 4d9b5e92b3471b647790762002cd24d2ac62729a Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 14 Mar 2015 15:59:01 +0000 Subject: [PATCH] Getting out if there is nothing to renumber, to prevent do_undo() from falling over when trying to renumber emptiness. Patch basically by Mark Majeres. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5137 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/nano.c | 6 +++--- src/search.c | 3 +-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8ead504..53ed221f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-03-14 Mark Majeres + * src/nano.c (renumber): Get out if there is nothing to renumber. + This prevents do_undo() from falling over when trying to renumber + emptiness. This fixes Savannah bug #44488, reported by Dennis. + 2015-03-08 Benno Schulenberg * src/proto.h, src/nano.c: Fix compilation with --enable-tiny plus --enable-nanorc. diff --git a/src/nano.c b/src/nano.c index e1a38b5c..38f3bb06 100644 --- a/src/nano.c +++ b/src/nano.c @@ -178,7 +178,8 @@ void renumber(filestruct *fileptr) { ssize_t line; - assert(fileptr != NULL); + if (fileptr == NULL) + return; line = (fileptr->prev == NULL) ? 0 : fileptr->prev->lineno; @@ -365,8 +366,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot, /* Renumber starting with the line after the original * file_bot. */ - if (file_bot_save->next != NULL) - renumber(file_bot_save->next); + renumber(file_bot_save->next); } /* Since the text has now been saved, remove it from the diff --git a/src/search.c b/src/search.c index 58c3a5ee..a3a85f0b 100644 --- a/src/search.c +++ b/src/search.c @@ -1373,8 +1373,7 @@ void update_history(filestruct **h, const char *s) bar = p->next; unlink_node(foo); delete_node(foo); - if (bar != NULL) - renumber(bar); + renumber(bar); } /* If the history is full, delete the beginning entry to make room -- 2.39.5