From fe17e47a8028c54126f48945b999416ce1e21483 Mon Sep 17 00:00:00 2001 From: Brandon Arrendondo Date: Tue, 23 Jun 2026 20:29:57 -0400 Subject: [PATCH] [rcore] Bounds-check gamepad index in GetGamepadAxisCount() and GetGamepadName() Both public getters indexed CORE.Input.Gamepad.axisCount[gamepad] / .name[gamepad] with an unvalidated gamepad argument -- an out-of-bounds read for gamepad < 0 or gamepad >= MAX_GAMEPADS. Every sibling gamepad accessor (IsGamepadAvailable, IsGamepadButton*, GetGamepadAxisMovement) already guards the index; add the same check, returning a safe default (0 / NULL). --- src/rcore.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rcore.c b/src/rcore.c index 7455e3597..c567059e3 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -3934,6 +3934,8 @@ bool IsGamepadAvailable(int gamepad) // Get gamepad internal name id const char *GetGamepadName(int gamepad) { + if ((gamepad < 0) || (gamepad >= MAX_GAMEPADS)) return NULL; + return CORE.Input.Gamepad.name[gamepad]; } @@ -3999,6 +4001,8 @@ int GetGamepadButtonPressed(void) // Get gamepad axis count int GetGamepadAxisCount(int gamepad) { + if ((gamepad < 0) || (gamepad >= MAX_GAMEPADS)) return 0; + return CORE.Input.Gamepad.axisCount[gamepad]; }