From: Benno Schulenberg Date: Wed, 25 Nov 2015 09:27:25 +0000 (+0000) Subject: Warning about a condition that should never occur, X-Git-Tag: v2.5.0~43 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=1b69dd629aac0a41dfd498a33a7cd190bb345ab5;p=nano.git Warning about a condition that should never occur, instead of silently continuing. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5440 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 2bab1d75..4907cf51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ of just the current line) is not needed for any kind of syntax, but only when there are multiline regexes. And check for this not on every keystroke in a burst, but just once. + * src/text.c (do_undo): Warn about a condition that should never + occur, instead of silently continuing. 2015-11-24 Benno Schulenberg * doc/syntax/makefile.nanorc: Also recognize the extensions .make and diff --git a/src/text.c b/src/text.c index c21f6f8b..fe6910ed 100644 --- a/src/text.c +++ b/src/text.c @@ -564,14 +564,17 @@ void do_undo(void) break; case ENTER: undidmsg = _("line break"); - if (f->next) { - filestruct *foo = f->next; - f->data = charealloc(f->data, strlen(f->data) + strlen(&f->next->data[u->mark_begin_x]) + 1); - strcat(f->data, &f->next->data[u->mark_begin_x]); - if (foo == openfile->filebot) - openfile->filebot = f; - unlink_node(foo); + filestruct *snipit = f->next; + if (snipit == NULL) { + statusbar(_("Internal error: line is missing. Please save your work.")); + return; } + f->data = charealloc(f->data, strlen(f->data) + + strlen(&f->next->data[u->mark_begin_x]) + 1); + strcat(f->data, &f->next->data[u->mark_begin_x]); + if (openfile->filebot == snipit) + openfile->filebot = f; + unlink_node(snipit); goto_line_posx(u->lineno, u->begin); break; case INSERT: