dinput: Avoid invalid rglDirection access when effect cAxes is 0.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2022-02-22 13:04:27 +01:00 committed by Alexandre Julliard
parent 71d0cdde89
commit 0bb48fcb6d
1 changed files with 3 additions and 2 deletions

View File

@ -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;