From c3b9ce3fdc4cd31f234b6e8f68ea9c233561a2a1 Mon Sep 17 00:00:00 2001 From: bicarus <202771338+bicarus-dev@users.noreply.github.com> Date: Mon, 26 Jan 2026 23:42:12 -0800 Subject: [PATCH] cfg: fix mouse names out of bounds (#535) ## Link to GitHub Issue, if one exists n/a ## Description of change Improper bounds check resulting in crash when binding mouse buttons beyond Mouse 5. ## Testing Tested with `Edit` function. --- src/spice2x/cfg/button.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/spice2x/cfg/button.cpp b/src/spice2x/cfg/button.cpp index 134439f..c6bf5cf 100644 --- a/src/spice2x/cfg/button.cpp +++ b/src/spice2x/cfg/button.cpp @@ -301,17 +301,17 @@ std::string Button::getDisplayString(rawinput::RawInputManager* manager) { switch (device->type) { case rawinput::MOUSE: { const char *btn = "Unknown"; - static const char *MOUSE_NAMES[] = { - "Left Mouse", - "Right Mouse", - "Middle Mouse", - "Mouse 1", - "Mouse 2", - "Mouse 3", - "Mouse 4", - "Mouse 5", - }; - if (vKey < sizeof(MOUSE_NAMES)) { + static const std::arrayMOUSE_NAMES = { + "Left Mouse", + "Right Mouse", + "Middle Mouse", + "Mouse 1", + "Mouse 2", + "Mouse 3", + "Mouse 4", + "Mouse 5", + }; + if (vKey < MOUSE_NAMES.size()) { btn = MOUSE_NAMES[vKey]; } return fmt::format("{} ({})", btn, device->desc);