From f59ef4422a6321044422c6e633be045486edc307 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 11 Nov 2023 13:10:54 +1100 Subject: [PATCH] [client] app: prevent possible out of bounds array access --- client/src/app.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/src/app.c b/client/src/app.c index e7d3a04a..c2145bd5 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -345,7 +345,10 @@ void app_handleKeyPress(int sc, int charcode) if (sc == KEY_ESC) app_setOverlay(false); else - g_state.io->KeysDown[sc] = true; + { + if (sc < sizeof(g_state.io->KeysDown)) + g_state.io->KeysDown[sc] = true; + } return; } @@ -388,7 +391,8 @@ void app_handleKeyRelease(int sc, int charcode) if (app_isOverlayMode()) { - g_state.io->KeysDown[sc] = false; + if (sc < sizeof(g_state.io->KeysDown)) + g_state.io->KeysDown[sc] = false; return; }