]> git.cameronkatri.com Git - bsdgames-darwin.git/commitdiff
cgram: fix undefined behavior when pressing function keys
authorrillig <rillig@NetBSD.org>
Sun, 21 Feb 2021 16:37:26 +0000 (16:37 +0000)
committerCameron Katri <me@cameronkatri.com>
Tue, 13 Apr 2021 19:28:32 +0000 (15:28 -0400)
The key codes for function keys are outside of the "range representable
by an unsigned char".  This resulted in parts of the screen being
cleaned.

cgram/cgram.c

index 7eaf592d73059e8c8b5ea5fa44510cc532468229..98f8bece421afd0839e9851a2da6302c254e1c9a 100644 (file)
@@ -325,7 +325,7 @@ loop(void)
                        done = true;
                        break;
                default:
                        done = true;
                        break;
                default:
-                       if (isalpha(ch)) {
+                       if (isascii(ch) && isalpha(ch)) {
                                if (substitute(ch)) {
                                        if (curx < strlen(lines.v[cury])) {
                                                curx++;
                                if (substitute(ch)) {
                                        if (curx < strlen(lines.v[cury])) {
                                                curx++;