forked from 0ad/0ad
Fixed a crash that happened for me in release mode when pressing the shift key. In Hotkey.cpp:594, there was a line like
if( !unified[(*itKey)-UNIFIED_SHIFT] ) accept = false; This was causing an index out of bounds when the key at *itKey was AND'ed with the HOTKEY_NEGATION_MASK and thus became greater than 65536 and way out of bounds of the array. For now I added a check that *itKey < HOTKEY_NEGATION_MASK, but maybe this is not the intended usage. This was SVN commit r4111.
This commit is contained in:
parent
3f91cbe3c1
commit
85959bb073
@ -19,6 +19,7 @@ struct SHotkeyMapping
|
||||
int mapsTo;
|
||||
bool negation;
|
||||
std::vector<int> requires;
|
||||
SHotkeyMapping() : mapsTo(-1) {}
|
||||
};
|
||||
|
||||
typedef std::vector<SHotkeyMapping> KeyMapping;
|
||||
@ -154,6 +155,7 @@ struct SHotkeyMappingGUI
|
||||
CStr mapsTo;
|
||||
bool negation;
|
||||
std::vector<int> requires;
|
||||
SHotkeyMappingGUI() : mapsTo(-1) {}
|
||||
};
|
||||
|
||||
typedef std::vector<SHotkeyMappingGUI> GuiMapping;
|
||||
@ -587,8 +589,10 @@ InReaction hotkeyInputHandler( const SDL_Event* ev )
|
||||
{
|
||||
if( !g_mouse_buttons[(*itKey)-SDLK_LAST] ) accept = false;
|
||||
}
|
||||
else
|
||||
else if( *itKey < HOTKEY_NEGATION_FLAG )
|
||||
{
|
||||
if( !unified[(*itKey)-UNIFIED_SHIFT] ) accept = false;
|
||||
}
|
||||
}
|
||||
|
||||
debug_assert(it->mapsTo < ARRAY_SIZE(hotkeys));
|
||||
|
Loading…
Reference in New Issue
Block a user