Rémi Bernon : dinput: Avoid invalid rglDirection access when effect cAxes is 0.
Module: wine Branch: master Commit: 0bb48fcb6dfd4839a640fe17a6fe4558a56f0cdf URL: https://source.winehq.org/git/wine.git/?a=commit;h=0bb48fcb6dfd4839a640fe17a... Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Feb 22 13:04:27 2022 +0100 dinput: Avoid invalid rglDirection access when effect cAxes is 0. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dinput/joystick_hid.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 00fd01b483a..80991e8c150 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -2296,7 +2296,7 @@ static void convert_directions_to_spherical( const DIEFFECT *in, DIEFFECT *out ) tmp = atan2( in->rglDirection[i], tmp ); out->rglDirection[i - 1] = tmp * 18000 / M_PI; } - out->rglDirection[in->cAxes - 1] = 0; + if (in->cAxes) out->rglDirection[in->cAxes - 1] = 0; out->cAxes = in->cAxes; break; case DIEFF_POLAR: @@ -2306,7 +2306,8 @@ static void convert_directions_to_spherical( const DIEFFECT *in, DIEFFECT *out ) out->cAxes = in->cAxes; break; case DIEFF_SPHERICAL: - for (i = 0; i < in->cAxes - 1; ++i) + if (!in->cAxes) i = 0; + else for (i = 0; i < in->cAxes - 1; ++i) { out->rglDirection[i] = in->rglDirection[i] % 36000; if (out->rglDirection[i] < 0) out->rglDirection[i] += 36000;
participants (1)
-
Alexandre Julliard