Prevent out-of-bounds array access

Fixes https://github.com/itgmania/itgmania/issues/27
This commit is contained in:
Martin Natano
2022-06-27 20:10:52 +02:00
parent 9b348090a7
commit 61f12e8165
2 changed files with 9 additions and 2 deletions
@@ -450,7 +450,7 @@ wchar_t InputHandler_MacOSX_HID::DeviceButtonToChar( DeviceButton button, bool b
{
CGEventRef event = CGEventCreate(nullptr);
CGEventFlags mods = CGEventGetFlags(event);
CFRelease(event);
CFRelease(event);
UInt32 nModifiers = bUseCurrentKeyModifiers ? (UInt32)mods : 0;
wchar_t sCharCode = KeyCodeToChar( iMacVirtualKey, nModifiers );
if( sCharCode != 0 )
+8 -1
View File
@@ -482,7 +482,14 @@ bool KeyboardDevice::DeviceButtonToMacVirtualKey( DeviceButton button, UInt8 &iM
}
bInited = true;
}
iMacVKOut = g_iDeviceButtonToMacVirtualKey[button];
if (button < sizeof(g_iDeviceButtonToMacVirtualKey))
{
iMacVKOut = g_iDeviceButtonToMacVirtualKey[button];
}
else
{
iMacVKOut = 0xFF;
}
return iMacVKOut != 0xFF;
}