diff src/video/windx5/SDL_dx5events.c @ 4383:daf9e6037596 SDL-1.2

Gregory Smith Another one for the "How did this ever work?" file: when DX5_HandleMessage is called with WM_ACTIVATEAPP, it goes past the end of the 2-element SDL_DIdev array and if there doesn't happen to be a 0 in the memory next to it, crashes. Patch against SVN attached.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 15 Nov 2009 17:21:24 +0000
parents 6cc2b35ac610
children 6800e2560310
line wrap: on
line diff
--- a/src/video/windx5/SDL_dx5events.c	Mon Nov 09 18:02:32 2009 +0000
+++ b/src/video/windx5/SDL_dx5events.c	Sun Nov 15 17:21:24 2009 +0000
@@ -559,13 +559,15 @@
 
 			active = (wParam && (GetForegroundWindow() == hwnd));
 			if ( active ) {
-				for ( i=0; SDL_DIdev[i]; ++i ) {
-					IDirectInputDevice2_Acquire(
+				for ( i=0; i<MAX_INPUTS; ++i ) {
+					if (SDL_DIdev[i] != NULL)
+						IDirectInputDevice2_Acquire(
 								SDL_DIdev[i]);
 				}
 			} else {
-				for ( i=0; SDL_DIdev[i]; ++i ) {
-					IDirectInputDevice2_Unacquire(
+				for ( i=0; i<MAX_INPUTS; ++i ) {
+					if (SDL_DIdev[i] != NULL) 
+						IDirectInputDevice2_Unacquire(
 								SDL_DIdev[i]);
 				}
 				mouse_lost = 1;