From 8a4ae19d6bbdfbdc8500e8697ca79777e0d57133 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Tue, 2 Jul 2024 16:54:22 -0300 Subject: [PATCH] qt: Fix invalid scancodes crashing Windows raw input --- src/qt/qt_winrawinputfilter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qt/qt_winrawinputfilter.cpp b/src/qt/qt_winrawinputfilter.cpp index 3ca091ae6..857ccef3b 100644 --- a/src/qt/qt_winrawinputfilter.cpp +++ b/src/qt/qt_winrawinputfilter.cpp @@ -199,9 +199,10 @@ WindowsRawInputFilter::keyboard_handle(PRAWINPUT raw) scancode = convert_scan_code(scancode); /* Remap it according to the list from the Registry */ - if (scancode != scancode_map[scancode]) - pclog("Scan code remap: %03X -> %03X\n", scancode, scancode); - scancode = scancode_map[scancode]; + if ((scancode < (sizeof(scancode_map) / sizeof(scancode_map[0]))) && (scancode != scancode_map[scancode])) { + pclog("Scan code remap: %03X -> %03X\n", scancode, scancode_map[scancode]); + scancode = scancode_map[scancode]; + } /* If it's not 0xFFFF, send it to the emulated keyboard.