Added some sanity checks to prevent buffer overflows.

Fixes Bugzilla #1074. (I think.)

--HG--
branch : SDL-1.2
This commit is contained in:
Ryan C. Gordon
2011-12-30 04:04:34 -05:00
parent 34a0d24b1e
commit b8cec255b2

View File

@@ -935,6 +935,10 @@ void HandleHat(SDL_Joystick *stick, Uint8 hat, int axis, int value)
SDL_logical_joydecl(SDL_Joystick *logicaljoy = NULL);
SDL_logical_joydecl(struct joystick_logical_mapping* hats = NULL);
if (stick->nhats <= hat) {
return; /* whoops, that shouldn't happen! */
}
the_hat = &stick->hwdata->hats[hat];
if ( value < 0 ) {
value = 0;
@@ -973,6 +977,9 @@ void HandleHat(SDL_Joystick *stick, Uint8 hat, int axis, int value)
static __inline__
void HandleBall(SDL_Joystick *stick, Uint8 ball, int axis, int value)
{
if ((stick->nballs <= ball) || (axis >= 2)) {
return; /* whoops, that shouldn't happen! */
}
stick->hwdata->balls[ball].axis[axis] += value;
}