Module: wine Branch: master Commit: 29894e1c9a15bd81ea84c4e3082e8e8ac8c01c85 URL: https://gitlab.winehq.org/wine/wine/-/commit/29894e1c9a15bd81ea84c4e3082e8e8...
Author: Ivo Ivanov logos128@gmail.com Date: Tue Aug 9 02:21:22 2022 +0300
dinput: Prevent a potential array overflow error during the conversion from spherical to Cartesian coordinates.
Signed-off-by: Ivo Ivanov logos128@gmail.com
---
dlls/dinput/joystick_hid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index ebebbee6eb2..3ea15009d8f 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -2350,7 +2350,8 @@ static void convert_directions_from_spherical( const DIEFFECT *in, DIEFFECT *out tmp = cos( in->rglDirection[i - 1] * M_PI / 18000 ) * 10000; for (j = 0; j < i; ++j) out->rglDirection[j] = round( out->rglDirection[j] * tmp / 10000.0 ); - out->rglDirection[i] = sin( in->rglDirection[i - 1] * M_PI / 18000 ) * 10000; + if (i < in->cAxes) + out->rglDirection[i] = sin( in->rglDirection[i - 1] * M_PI / 18000 ) * 10000; } out->cAxes = in->cAxes; break;