summaryrefslogtreecommitdiff
path: root/soh/src/code
diff options
context:
space:
mode:
authorChristopher Leggett <chris@leggett.dev>2022-12-12 13:35:34 -0500
committerGitHub <noreply@github.com>2022-12-12 13:35:34 -0500
commite4ebdf76d96f37da069abcc81694e4840c84c91c (patch)
tree3a5ba2557e4a35ec2aa4f406ef9e2ffd50509839 /soh/src/code
parent72d53d61edb5a653c7cc86271ec64ddae90b72ad (diff)
Fixes crash due to OOB soundfont access. (#2157)
Diffstat (limited to 'soh/src/code')
-rw-r--r--soh/src/code/audio_playback.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/soh/src/code/audio_playback.c b/soh/src/code/audio_playback.c
index a10034a14..d33692ed1 100644
--- a/soh/src/code/audio_playback.c
+++ b/soh/src/code/audio_playback.c
@@ -376,7 +376,7 @@ Drum* Audio_GetDrum(s32 fontId, s32 drumId) {
}
SoundFontSound* Audio_GetSfx(s32 fontId, s32 sfxId) {
- SoundFontSound* sfx;
+ SoundFontSound* sfx = NULL;
if (fontId == 0xFF) {
return NULL;
@@ -388,13 +388,15 @@ SoundFontSound* Audio_GetSfx(s32 fontId, s32 sfxId) {
}
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]);
- sfx = &sf->soundEffects[sfxId];
+ if (sfxId < sf->numSfx) {
+ sfx = &sf->soundEffects[sfxId];
+ }
if (sfx == NULL) {
gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x5000000;
}
- if (sfx->sample == NULL) {
+ if (sfx != NULL && sfx->sample == NULL) {
return NULL;
}