Rémi Bernon : dinput: Check for DIEFF_POLAR axes count before capacity.

Alexandre Julliard julliard at winehq.org
Wed Nov 10 15:34:48 CST 2021


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

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Wed Nov 10 10:52:26 2021 +0100

dinput: Check for DIEFF_POLAR axes count before capacity.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51922
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput/joystick_hid.c | 4 ++--
 dlls/dinput8/tests/hid.c   | 6 +-----
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index dd77f557e3e..cec02ccd74a 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -2063,14 +2063,14 @@ static HRESULT WINAPI hid_joystick_effect_GetParameters( IDirectInputEffect *ifa
         if (!direction_flags) return DIERR_INVALIDPARAM;
 
         count = params->cAxes = impl->params.cAxes;
-        if (capacity < params->cAxes) return DIERR_MOREDATA;
         if (!count) params->dwFlags &= ~(DIEFF_CARTESIAN | DIEFF_POLAR | DIEFF_SPHERICAL);
+        if ((direction_flags & DIEFF_POLAR) && count != 2) return DIERR_INVALIDPARAM;
+        if (capacity < params->cAxes) return DIERR_MOREDATA;
 
         if (direction_flags & DIEFF_SPHERICAL)
             memcpy( directions, impl->params.rglDirection, count * sizeof(LONG) );
         else if (direction_flags & DIEFF_POLAR)
         {
-            if (count != 2) return DIERR_INVALIDPARAM;
             directions[0] = (impl->params.rglDirection[0] + 9000) % 36000;
             if (directions[0] < 0) directions[0] += 36000;
         }
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index 54109593a18..5b01ea3a68a 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -6138,11 +6138,7 @@ static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file, DWO
         desc.dwFlags = DIEFF_POLAR;
         desc.cAxes = 1;
         hr = IDirectInputEffect_GetParameters( effect, &desc, DIEP_DIRECTION );
-        if (i != 2)
-        {
-            todo_wine_if( i == 3 )
-            ok( hr == DIERR_INVALIDPARAM, "GetParameters returned %#x\n", hr );
-        }
+        if (i != 2) ok( hr == DIERR_INVALIDPARAM, "GetParameters returned %#x\n", hr );
         else ok( hr == DIERR_MOREDATA, "GetParameters returned %#x\n", hr );
         desc.cAxes = 3;
         memset( desc.rglDirection, 0xcd, 3 * sizeof(LONG) );




More information about the wine-cvs mailing list