From ee43ea6a749856051b2d7ea1cfc2c20ca5095452 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Sun, 22 Apr 2007 15:04:05 +0000 Subject: [PATCH] in backup_lines(), avoid a segfault when the mark begins and ends on the line after the last line of the paragraph git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4099 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/text.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1942c631..df3e34f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-04-22 David Lawrence Ramsey + + * text.c (backup_lines): Avoid a segfault when the mark begins + and ends on the line after the last line of the paragraph. + 2007-04-21 David Lawrence Ramsey * files.c (do_writeout): If we're in restricted mode, we're not diff --git a/src/text.c b/src/text.c index 5746d3b6..58219fe0 100644 --- a/src/text.c +++ b/src/text.c @@ -1212,9 +1212,16 @@ void backup_lines(filestruct *first_line, size_t par_len) * line, putting first_line, edittop, current, and mark_begin at the * same lines in the copied paragraph that they had in the original * paragraph. */ - if (openfile->current != openfile->fileage) + if (openfile->current != openfile->fileage) { top = openfile->current->prev; - else +#ifndef NANO_TINY + if (old_mark_set && + openfile->current->lineno == mb_lineno_save) { + openfile->mark_begin = openfile->current; + openfile->mark_begin_x = mark_begin_x_save; + } +#endif + } else top = openfile->current; for (i = par_len; i > 0 && top != NULL; i--) { if (top->lineno == fl_lineno_save) -- 2.39.5