joy.cpl: Prevent crash on IDirectInputEffect_Release.

This commit is contained in:
Lucas Zawacki 2012-08-20 03:39:07 -03:00 committed by Alexandre Julliard
parent cda7633775
commit e3af37eb1c
1 changed files with 3 additions and 2 deletions

View File

@ -90,6 +90,7 @@ static BOOL CALLBACK enum_callback(const DIDEVICEINSTANCEW *instance, void *cont
joystick->num_buttons = caps.dwButtons;
joystick->num_axes = caps.dwAxes;
joystick->forcefeedback = caps.dwFlags & DIDC_FORCEFEEDBACK;
joystick->num_effects = 0;
if (joystick->forcefeedback) data->num_ff++;
@ -130,10 +131,10 @@ static void destroy_joysticks(struct JoystickData *data)
for (i = 0; i < data->num_joysticks; i++)
{
if (data->joysticks[i].forcefeedback)
if (data->joysticks[i].forcefeedback && data->joysticks[i].num_effects > 0)
{
for (j = 0; j < data->joysticks[i].num_effects; j++)
IDirectInputEffect_Release(data->joysticks[i].effects[j].effect);
IDirectInputEffect_Release(data->joysticks[i].effects[j].effect);
HeapFree(GetProcessHeap(), 0, data->joysticks[i].effects);
}