Fix memory overflow

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12215 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2012-12-08 22:35:27 +00:00
parent bebf7f85c9
commit cf4dd96871

View File

@ -173,10 +173,9 @@ bool GamePadDevice::processAndMapInput(Input::InputType type, const int id,
if (type == Input::IT_STICKMOTION) if (type == Input::IT_STICKMOTION)
{ {
if (id >= m_axis_count && id != Input::HAT_H_ID && // this gamepad doesn't even have that many axes
id != Input::HAT_V_ID) if (id >= m_axis_count) return false;
return false; // this gamepad doesn't even have that many axes
if (player != NULL) if (player != NULL)
{ {
// going to negative from positive // going to negative from positive
@ -193,7 +192,7 @@ bool GamePadDevice::processAndMapInput(Input::InputType type, const int id,
resetAxisDirection(id, Input::AD_NEGATIVE, player); resetAxisDirection(id, Input::AD_NEGATIVE, player);
} }
} }
if (value > 0) m_prevAxisDirections[id] = Input::AD_POSITIVE; if (value > 0) m_prevAxisDirections[id] = Input::AD_POSITIVE;
else if(value < 0) m_prevAxisDirections[id] = Input::AD_NEGATIVE; else if(value < 0) m_prevAxisDirections[id] = Input::AD_NEGATIVE;