(MFi) Prevent crash when controller player index is unset (-1) (#14999)

This commit is contained in:
serakeri 2023-02-21 00:10:00 -05:00 committed by GitHub
parent 347ea8157c
commit e0c9781b50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -166,7 +166,7 @@ static void apple_gamecontroller_joypad_poll(void)
for (GCController *controller in [GCController controllers])
{
/* If we have not assigned a slot to this controller yet, ignore it. */
if (controller && (controller.playerIndex < MAX_USERS))
if (controller && (controller.playerIndex >= 0) && (controller.playerIndex < MAX_USERS))
apple_gamecontroller_joypad_poll_internal(controller, (uint32_t)controller.playerIndex);
}
}