Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/cgram cgram: fix undefined behavior when pressing func...



details:   https://anonhg.NetBSD.org/src/rev/7d8e79bbd4ce
branches:  trunk
changeset: 980904:7d8e79bbd4ce
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 21 16:37:26 2021 +0000

description:
cgram: fix undefined behavior when pressing function keys

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.

diffstat:

 games/cgram/cgram.c |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r aefe0c2ec3d6 -r 7d8e79bbd4ce games/cgram/cgram.c
--- a/games/cgram/cgram.c       Sun Feb 21 16:33:22 2021 +0000
+++ b/games/cgram/cgram.c       Sun Feb 21 16:37:26 2021 +0000
@@ -325,7 +325,7 @@
                        done = true;
                        break;
                default:
-                       if (isalpha(ch)) {
+                       if (isascii(ch) && isalpha(ch)) {
                                if (substitute(ch)) {
                                        if (curx < strlen(lines.v[cury])) {
                                                curx++;



Home | Main Index | Thread Index | Old Index