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/813bbb1f7b25
branches:  trunk
changeset: 1018939:813bbb1f7b25
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 6d73fb66e2c9 -r 813bbb1f7b25 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