Module: wine Branch: master Commit: bbdec47b966ed94fc72e13e91c943c6b1a34682e URL: https://gitlab.winehq.org/wine/wine/-/commit/bbdec47b966ed94fc72e13e91c943c6...
Author: Rémi Bernon rbernon@codeweavers.com Date: Wed Nov 15 16:01:43 2023 +0100
winebus.sys: Fix incorrect hid_device_set index check.
Instead of checking it in set_report_from_joystick_event.
---
dlls/winebus.sys/bus_sdl.c | 6 ++---- dlls/winebus.sys/hid.c | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 9b0e7226fa5..ed9d3aed4bd 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -841,8 +841,7 @@ static BOOL set_report_from_joystick_event(struct sdl_device *impl, SDL_Event *e { SDL_JoyAxisEvent *ie = &event->jaxis;
- if (ie->axis >= ARRAY_SIZE(absolute_axis_usages)) break; - hid_device_set_abs_axis(iface, ie->axis, ie->value); + if (!hid_device_set_abs_axis(iface, ie->axis, ie->value)) break; bus_event_queue_input_report(&event_queue, iface, state->report_buf, state->report_len); break; } @@ -850,8 +849,7 @@ static BOOL set_report_from_joystick_event(struct sdl_device *impl, SDL_Event *e { SDL_JoyBallEvent *ie = &event->jball;
- if (ie->ball >= ARRAY_SIZE(relative_axis_usages) / 2) break; - hid_device_set_rel_axis(iface, 2 * ie->ball, ie->xrel); + if (!hid_device_set_rel_axis(iface, 2 * ie->ball, ie->xrel)) break; hid_device_set_rel_axis(iface, 2 * ie->ball + 1, ie->yrel); bus_event_queue_input_report(&event_queue, iface, state->report_buf, state->report_len); break; diff --git a/dlls/winebus.sys/hid.c b/dlls/winebus.sys/hid.c index c5543e081ae..6d2b484ccca 100644 --- a/dlls/winebus.sys/hid.c +++ b/dlls/winebus.sys/hid.c @@ -1376,7 +1376,7 @@ BOOL hid_device_set_abs_axis(struct unix_device *iface, ULONG index, LONG value) { struct hid_device_state *state = &iface->hid_device_state; ULONG offset = state->abs_axis_start + index * 4; - if (index > state->abs_axis_count) return FALSE; + if (index >= state->abs_axis_count) return FALSE; *(ULONG *)(state->report_buf + offset) = LE_ULONG(value); return TRUE; } @@ -1385,7 +1385,7 @@ BOOL hid_device_set_rel_axis(struct unix_device *iface, ULONG index, LONG value) { struct hid_device_state *state = &iface->hid_device_state; ULONG offset = state->rel_axis_start + index * 4; - if (index > state->rel_axis_count) return FALSE; + if (index >= state->rel_axis_count) return FALSE; *(ULONG *)(state->report_buf + offset) = LE_ULONG(value); return TRUE; } @@ -1395,7 +1395,7 @@ BOOL hid_device_set_button(struct unix_device *iface, ULONG index, BOOL is_set) struct hid_device_state *state = &iface->hid_device_state; ULONG offset = state->button_start + (index / 8); BYTE mask = (1 << (index % 8)); - if (index > state->button_count) return FALSE; + if (index >= state->button_count) return FALSE; if (is_set) state->report_buf[offset] |= mask; else state->report_buf[offset] &= ~mask; return TRUE;