summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEblo <7004497+Eblo@users.noreply.github.com>2025-12-18 09:21:18 -0500
committerGitHub <noreply@github.com>2025-12-18 09:21:18 -0500
commitcfbfdc5d1bfbfbee7f839866e366ac996855e4c5 (patch)
tree7e7a4756f66a67d8fc7b698fef10220618af9ed4
parenta2e8b62def688528635da207f99b390b367c7ba8 (diff)
Fix OOB in AudioSeq_ResetReverb (#1397)
-rw-r--r--mm/src/audio/sequence.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/mm/src/audio/sequence.c b/mm/src/audio/sequence.c
index a2b70389e..0b192b67b 100644
--- a/mm/src/audio/sequence.c
+++ b/mm/src/audio/sequence.c
@@ -895,10 +895,15 @@ u8 AudioSeq_ResetReverb(void) {
} else {
while (fadeReverb != 0) {
if (fadeReverb & 1) {
- AUDIOCMD_GLOBAL_SET_REVERB_DATA(
- reverbIndex, REVERB_DATA_TYPE_SETTINGS,
- (uintptr_t)(gReverbSettingsTable[(u8)(sResetAudioHeapSeqCmd & 0xFF)] + reverbIndex));
- AudioThread_ScheduleProcessCmds();
+ //! @bug Triggering the ending cutscene during final hours can give an index of 12 here, which is
+ // OOB. This does not normally happen in the game, but Triforce Hunt makes this a possibility.
+ // Follow a condition similar to what is found in Audio_ResetForAudioHeapStep2.
+ if (((u8)(sResetAudioHeapSeqCmd & 0xFF)) < ARRAY_COUNT(gReverbSettingsTable)) {
+ AUDIOCMD_GLOBAL_SET_REVERB_DATA(
+ reverbIndex, REVERB_DATA_TYPE_SETTINGS,
+ (uintptr_t)(gReverbSettingsTable[(u8)(sResetAudioHeapSeqCmd & 0xFF)] + reverbIndex));
+ AudioThread_ScheduleProcessCmds();
+ }
}
reverbIndex++;
fadeReverb = fadeReverb >> 1;