diff options
author | Max Horn | 2010-10-27 15:15:59 +0000 |
---|---|---|
committer | Max Horn | 2010-10-27 15:15:59 +0000 |
commit | b5e41b3a82a6f39302b34dd0b582265d3028d8ed (patch) | |
tree | 0f4bf8d6cdbc79d5769ead76dfa9898716dae25d /engines/sword25 | |
parent | 9ab69ab6f459b92e3283fac51b26326a3490f220 (diff) | |
download | scummvm-rg350-b5e41b3a82a6f39302b34dd0b582265d3028d8ed.tar.gz scummvm-rg350-b5e41b3a82a6f39302b34dd0b582265d3028d8ed.tar.bz2 scummvm-rg350-b5e41b3a82a6f39302b34dd0b582265d3028d8ed.zip |
SWORD25: Fix out of bounds writes when pressing keys like ctrl or F-keys
This fixes a crash one got by quitting via the GMM.
svn-id: r53876
Diffstat (limited to 'engines/sword25')
-rw-r--r-- | engines/sword25/input/inputengine.cpp | 3 | ||||
-rw-r--r-- | engines/sword25/input/inputengine.h | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/engines/sword25/input/inputengine.cpp b/engines/sword25/input/inputengine.cpp index 5d996d7f54..a85096bc2f 100644 --- a/engines/sword25/input/inputengine.cpp +++ b/engines/sword25/input/inputengine.cpp @@ -169,6 +169,7 @@ void InputEngine::testForLeftDoubleClick() { } void InputEngine::alterKeyboardState(int keycode, byte newState) { + assert(keycode < ARRAYSIZE(_keyboardState[_currentState])); _keyboardState[_currentState][keycode] = newState; } @@ -193,10 +194,12 @@ int InputEngine::getMouseY() { } bool InputEngine::isKeyDown(uint keyCode) { + assert(keyCode < ARRAYSIZE(_keyboardState[_currentState])); return (_keyboardState[_currentState][keyCode] & 0x80) != 0; } bool InputEngine::wasKeyDown(uint keyCode) { + assert(keyCode < ARRAYSIZE(_keyboardState[_currentState])); return ((_keyboardState[_currentState][keyCode] & 0x80) == 0) && ((_keyboardState[_currentState ^ 1][keyCode] & 0x80) != 0); } diff --git a/engines/sword25/input/inputengine.h b/engines/sword25/input/inputengine.h index 20bea21a72..1734a19567 100644 --- a/engines/sword25/input/inputengine.h +++ b/engines/sword25/input/inputengine.h @@ -309,7 +309,7 @@ private: void testForLeftDoubleClick(); void alterKeyboardState(int keycode, byte newState); - byte _keyboardState[2][256]; + byte _keyboardState[2][512]; bool _leftMouseState[2]; bool _rightMouseState[2]; uint _currentState; |