From 24df68ea33fd7b9ffaadf102a0c758c2b4c7528b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 7 Oct 2016 16:32:58 -0700 Subject: [PATCH] Fixed bug 2833 - Access Violation on SDL_PollEvent after init, delay and quit of joystick subsystem Jan Klass Not sure if this is limited to the joystick subsystem, but I created a minimal program for reproducibility, which is attached. The issue occurs with my gamepad Razer Onza (an xbox-style gamepad) plugged in. On initialization, the gamepad is being recognized. After quitting the subsystem, the poll will receive the joystick added event, which it instantly handles itself, calling SDL_SYS_JoystickDetect again, which this time calls IDirectInput8_EnumDevices with dinput = NULL (after it was released on quit). This seems to lead to an access violation within said function, which I have no source for. --- src/joystick/windows/SDL_windowsjoystick.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c index 0628627d3e52c..e528afa7fbf5d 100644 --- a/src/joystick/windows/SDL_windowsjoystick.c +++ b/src/joystick/windows/SDL_windowsjoystick.c @@ -509,6 +509,9 @@ SDL_SYS_JoystickQuit(void) SDL_DINPUT_JoystickQuit(); SDL_XINPUT_JoystickQuit(); + + s_bDeviceAdded = SDL_FALSE; + s_bDeviceRemoved = SDL_FALSE; } /* return the stable device guid for this device index */