From 9a6097924216bc9a1c4f585541fc417b635301de Mon Sep 17 00:00:00 2001 From: SSimco <37044560+SSimco@users.noreply.github.com> Date: Sun, 11 Sep 2022 03:00:02 +0300 Subject: [PATCH] Linux: Avoid out-of-bounds raw keycode array access (#226) --- src/gui/CemuApp.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 8563ae2c..c3270bed 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -170,12 +170,16 @@ int CemuApp::FilterEvent(wxEvent& event) { const auto& key_event = (wxKeyEvent&)event; wxGetKeyState(wxKeyCode::WXK_F17); - g_window_info.keydown[fix_raw_keycode(key_event.GetRawKeyCode(), key_event.GetRawKeyFlags())] = true; + uint32 keycode=fix_raw_keycode(key_event.GetRawKeyCode(), key_event.GetRawKeyFlags()); + if(keycode<256) + g_window_info.keydown[keycode] = true; } else if(event.GetEventType() == wxEVT_KEY_UP) { const auto& key_event = (wxKeyEvent&)event; - g_window_info.keydown[fix_raw_keycode(key_event.GetRawKeyCode(), key_event.GetRawKeyFlags())] = false; + uint32 keycode=fix_raw_keycode(key_event.GetRawKeyCode(), key_event.GetRawKeyFlags()); + if(keycode<256) + g_window_info.keydown[keycode] = false; } return wxApp::FilterEvent(event);