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/6463daf33378
branches:  trunk
changeset: 959680:6463daf33378
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 1f051b74b982 -r 6463daf33378 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