Brendan Shanks : dinput: Fix IDirectInputEffect::SetParameters() behavior with NULL effect parameters.

Alexandre Julliard julliard at winehq.org
Thu Mar 26 16:27:23 CDT 2020


Module: wine
Branch: master
Commit: f66517b5a27057243912f3a7c4a41a291ab2bfb8
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f66517b5a27057243912f3a7c4a41a291ab2bfb8

Author: Brendan Shanks <bshanks at codeweavers.com>
Date:   Wed Mar 25 16:31:30 2020 -0700

dinput: Fix IDirectInputEffect::SetParameters() behavior with NULL effect parameters.

Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput/effect_linuxinput.c | 8 +++++++-
 dlls/dinput/tests/joystick.c    | 2 --
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c
index cc2df3ce87..ef21ecaa30 100644
--- a/dlls/dinput/effect_linuxinput.c
+++ b/dlls/dinput/effect_linuxinput.c
@@ -499,6 +499,9 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
     dump_DIEFFECT(peff, &This->guid, dwFlags);
 
     if (dwFlags & DIEP_AXES) {
+	if (!(peff->rgdwAxes))
+	    return DIERR_INVALIDPARAM;
+
 	/* the linux input effect system only supports one or two axes */
 	if (peff->cAxes > 2)
 	    return DIERR_INVALIDPARAM;
@@ -511,6 +514,9 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
      * different opinions about which way direction "0" is.  directx has 0 along the x
      * axis (left), linux has it along the y axis (down). */ 
     if (dwFlags & DIEP_DIRECTION) {
+	if (!(peff->rglDirection))
+	    return DIERR_INVALIDPARAM;
+
 	if (peff->cAxes == 1) {
 	    if (peff->dwFlags & DIEFF_CARTESIAN) {
 		if (dwFlags & DIEP_AXES) {
@@ -629,7 +635,7 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
     if (dwFlags & DIEP_TYPESPECIFICPARAMS)
     {
         if (!(peff->lpvTypeSpecificParams))
-            return DIERR_INCOMPLETEEFFECT;
+            return DIERR_INVALIDPARAM;
 
         if (type == DIEFT_PERIODIC)
         {
diff --git a/dlls/dinput/tests/joystick.c b/dlls/dinput/tests/joystick.c
index fb777e71ae..a3d7440367 100644
--- a/dlls/dinput/tests/joystick.c
+++ b/dlls/dinput/tests/joystick.c
@@ -606,7 +606,6 @@ static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
             ok(hr==DI_OK,"IDirectInputEffect_Initialize failed: %08x\n", hr);
 
             /* Test SetParameters with NULL pointers */
-            todo_wine {
             tmp = effect_data.eff.rgdwAxes;
             effect_data.eff.rgdwAxes = NULL;
             hr = IDirectInputEffect_SetParameters(effect, &effect_data.eff, DIEP_AXES);
@@ -624,7 +623,6 @@ static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
             hr = IDirectInputEffect_SetParameters(effect, &effect_data.eff, DIEP_TYPESPECIFICPARAMS);
             ok(hr==DIERR_INVALIDPARAM,"IDirectInputEffect_SetParameters should fail with INVALIDPARAM, got: %08x\n", hr);
             effect_data.eff.lpvTypeSpecificParams = tmp;
-            }
 
             hr = IDirectInputEffect_SetParameters(effect, &effect_data.eff, DIEP_AXES | DIEP_DIRECTION |
                                                   DIEP_TYPESPECIFICPARAMS);




More information about the wine-cvs mailing list