[Scummvm-cvs-logs] SF.net SVN: scummvm:[53876] scummvm/trunk/engines/sword25/input

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Oct 27 17:15:59 CEST 2010


Revision: 53876
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53876&view=rev
Author:   fingolfin
Date:     2010-10-27 15:15:59 +0000 (Wed, 27 Oct 2010)

Log Message:
-----------
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.

Modified Paths:
--------------
    scummvm/trunk/engines/sword25/input/inputengine.cpp
    scummvm/trunk/engines/sword25/input/inputengine.h

Modified: scummvm/trunk/engines/sword25/input/inputengine.cpp
===================================================================
--- scummvm/trunk/engines/sword25/input/inputengine.cpp	2010-10-27 14:32:29 UTC (rev 53875)
+++ scummvm/trunk/engines/sword25/input/inputengine.cpp	2010-10-27 15:15:59 UTC (rev 53876)
@@ -169,6 +169,7 @@
 }
 
 void InputEngine::alterKeyboardState(int keycode, byte newState) {
+	assert(keycode < ARRAYSIZE(_keyboardState[_currentState]));
 	_keyboardState[_currentState][keycode] = newState;
 }
 
@@ -193,10 +194,12 @@
 }
 
 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);
 }

Modified: scummvm/trunk/engines/sword25/input/inputengine.h
===================================================================
--- scummvm/trunk/engines/sword25/input/inputengine.h	2010-10-27 14:32:29 UTC (rev 53875)
+++ scummvm/trunk/engines/sword25/input/inputengine.h	2010-10-27 15:15:59 UTC (rev 53876)
@@ -309,7 +309,7 @@
 	void testForLeftDoubleClick();
 	void alterKeyboardState(int keycode, byte newState);
 
-	byte _keyboardState[2][256];
+	byte _keyboardState[2][512];
 	bool _leftMouseState[2];
 	bool _rightMouseState[2];
 	uint _currentState;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list