From 36af005cc49a0e294c549a18490fbb4c0f67d9cb Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Thu, 27 Jun 2024 18:19:19 +0200 Subject: [PATCH] another emerald UB --- src/wireless_communication_status_screen.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/wireless_communication_status_screen.c b/src/wireless_communication_status_screen.c index 693e22052..793c589d2 100644 --- a/src/wireless_communication_status_screen.c +++ b/src/wireless_communication_status_screen.c @@ -381,6 +381,13 @@ static u32 CountPlayersInGroupAndGetActivity(struct RfuPlayer * player, u32 * gr for (i = 0; i < ARRAY_COUNT(sActivityGroupInfo); i++) { +#ifdef UBFIX + // GROUPTYPE_NONE is 0xFF, and shouldn't be used as an index into groupCounts. + // In theory the only activity with this group type (ACTIVITY_SEARCH) wouldn't + // satisfy the condition below, but not necessarily. + if (group_type(i) == GROUPTYPE_NONE) + continue; +#endif if (activity == group_activity(i) && player->groupScheduledAnim == UNION_ROOM_SPAWN_IN) { if (group_players(i) == 0)