nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit d4d2840f5d456adecfbc5ddfcb08e4550f55ae9e
parent 119ec47072824e1a3f01fa81d7573a784cebfed0
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 28 Sep 2022 16:21:10 +0200

filtering: when returning to a line number, ensure it is within range

The function line_from_number() can handle only line numbers that exist,
and will crash otherwise.  (The lack of checks makes the function fast.)

This fixes https://savannah.gnu.org/bugs/?63120.

Bug existed since commit d1e28417 from five weeks ago.

Diffstat:
Msrc/search.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/search.c b/src/search.c @@ -747,7 +747,11 @@ void goto_line_posx(ssize_t linenumber, size_t pos_x) recook |= perturbed; #endif - openfile->current = line_from_number(linenumber); + if (linenumber < openfile->filebot->lineno) + openfile->current = line_from_number(linenumber); + else + openfile->current = openfile->filebot; + openfile->current_x = pos_x; openfile->placewewant = xplustabs();