Fixes crash due to OOB soundfont access. (#2157)

This commit is contained in:
Christopher Leggett 2022-12-12 13:35:34 -05:00 committed by GitHub
parent 72d53d61ed
commit e4ebdf76d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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]);
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;
}