diff --git a/ChangeLog b/ChangeLog index b8ead50483495d3e517b3d0ae789f15b6c9c580d..53ed221f81ca30f86637e76b00778c0e0f342a0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-03-14 Mark Majeres <mark@engine12.com> + * 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 <bensberg@justemail.net> * 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 e1a38b5c464d1a8c6e98308df735687dceb235a7..38f3bb0648db571159268c32a2e768074a984c51 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 58c3a5ee2ceb245fff7bb4a48c6b5598190af949..a3a85f0b1319426289b95723a312ea2773037e3d 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