From 8a39969a617ab066635fd80b7588f6c6a0a460a2 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 7 May 2021 21:07:04 +1000 Subject: [PATCH] SDLControllerInterface: Prevent crash with out-of-range buttons --- src/frontend-common/sdl_controller_interface.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/frontend-common/sdl_controller_interface.cpp b/src/frontend-common/sdl_controller_interface.cpp index 07122ab18..249b4bd0c 100644 --- a/src/frontend-common/sdl_controller_interface.cpp +++ b/src/frontend-common/sdl_controller_interface.cpp @@ -629,6 +629,9 @@ bool SDLControllerInterface::HandleControllerAxisEvent(const SDL_ControllerAxisE if (DoEventHook(Hook::Type::Axis, it->player_id, ev->axis, value)) return true; + if (ev->axis >= MAX_NUM_AXES) + return false; + const AxisCallback& cb = it->axis_mapping[ev->axis][AxisSide::Full]; if (cb) { @@ -707,6 +710,9 @@ bool SDLControllerInterface::HandleControllerButtonEvent(const SDL_ControllerBut return true; } + if (ev->button >= MAX_NUM_BUTTONS) + return false; + const ButtonCallback& cb = it->button_mapping[ev->button]; if (cb) {