[PATCH] joy.cpl: Check if effect is allocated before releasing it

Tim Schumacher timschumi at gmx.de
Sat May 18 14:02:58 CDT 2019


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