nano

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

commit 3fb8efc8f2ea9bc33560c8c8681509a9a7fc95cd
parent 9ae84071eb645beb8898469845b2f1a8dab9d901
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri, 22 Mar 2024 16:17:49 +0100

input: prevent 'macro_length' from underflowing when hammering M-:

Normally, when recording a macro, users will make their keystrokes
slowly and carefully, and will most likely wait to see the effect
of the previous keystroke before making the next.  So, the chances
of two `recordmacro` keystrokes coming in in quick succession is
normally nil.  The 'macro_length' variable just needs a guard to
prevent it from underflowing when someone is hammering the keys.

This fixes https://savannah.gnu.org/bugs/?65394 in a better way.

Diffstat:
Msrc/winio.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/winio.c b/src/winio.c @@ -91,7 +91,8 @@ void add_to_macrobuffer(int code) /* Remove the last key code plus any leading Esc codes from macro buffer. */ void snip_last_keystroke(void) { - macro_length--; + if (macro_length > 0) + macro_length--; while (macro_length > 0 && macro_buffer[macro_length - 1] == '\x1b') macro_length--; }