[Commits] SDL: Fixed bug 1337 - joystick crash due to heap corruption with...
libsdl.org revision control
commits-owner at libsdl.org
Sun Jan 1 14:03:14 PST 2012
details: http://hg.libsdl.org/SDL/rev/964d13f789e2
changeset: 6145:964d13f789e2
user: Sam Lantinga <slouken at libsdl.org>
date: Sun Jan 01 16:58:00 2012 -0500
description:
Fixed bug 1337 - joystick crash due to heap corruption with btnx
diffstat:
src/joystick/SDL_joystick.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diffs (51 lines):
diff -r 67268d47c17b -r 964d13f789e2 src/joystick/SDL_joystick.c
--- a/src/joystick/SDL_joystick.c Sat Dec 31 13:29:09 2011 -0500
+++ b/src/joystick/SDL_joystick.c Sun Jan 01 16:58:00 2012 -0500
@@ -427,6 +427,11 @@
{
int posted;
+ /* Make sure we're not getting garbage events */
+ if (axis >= joystick->naxes) {
+ return 0;
+ }
+
/* Update internal joystick state */
joystick->axes[axis] = value;
@@ -454,6 +459,11 @@
{
int posted;
+ /* Make sure we're not getting garbage events */
+ if (hat >= joystick->nhats) {
+ return 0;
+ }
+
/* Update internal joystick state */
joystick->hats[hat] = value;
@@ -482,6 +492,11 @@
{
int posted;
+ /* Make sure we're not getting garbage events */
+ if (ball >= joystick->nballs) {
+ return 0;
+ }
+
/* Update internal mouse state */
joystick->balls[ball].dx += xrel;
joystick->balls[ball].dy += yrel;
@@ -526,6 +541,11 @@
}
#endif /* !SDL_EVENTS_DISABLED */
+ /* Make sure we're not getting garbage events */
+ if (button >= joystick->nbuttons) {
+ return 0;
+ }
+
/* Update internal joystick state */
joystick->buttons[button] = state;
More information about the commits
mailing list