[PATCH] joy.cpl: Check if effect is allocated before releasing it
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Sun May 19 03:49:14 CDT 2019
Hi Tim,
It would be better to stop the adding of NULL effects.
function ff_effects_callback
hr = IDirectInputDevice2_CreateEffect(
joystick->device, &pdei->guid, &dieffect,
&joystick->effects[joystick->cur_effect].effect, NULL);
/* hr is assigned but never checked. */
Best Regards
Alistair.
On 19/5/19 5:02 am, Tim Schumacher wrote:
> Since IDirectInputEffect_Release(obj) is just a macro for (obj)->Release(),
> the program crashes if the effect we are trying to release is null.
> This mostly happens when the effect failed to allocate in the first place.
>
> Signed-off-by: Tim Schumacher <timschumi at gmx.de>
> ---
> dlls/joy.cpl/main.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c
> index 9768917641..06084f3166 100644
> --- a/dlls/joy.cpl/main.c
> +++ b/dlls/joy.cpl/main.c
> @@ -137,7 +137,8 @@ static void destroy_joysticks(struct JoystickData *data)
> 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);
> + if (data->joysticks[i].effects[j].effect)
> + IDirectInputEffect_Release(data->joysticks[i].effects[j].effect);
>
> HeapFree(GetProcessHeap(), 0, data->joysticks[i].effects);
> }
> --
> 2.21.0
>
>
>
More information about the wine-devel
mailing list