summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--soh/src/code/audio_load.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/soh/src/code/audio_load.c b/soh/src/code/audio_load.c
index 6b136eacd..85c0ed709 100644
--- a/soh/src/code/audio_load.c
+++ b/soh/src/code/audio_load.c
@@ -297,18 +297,19 @@ void AudioLoad_InitSampleDmaBuffers(s32 arg0) {
gAudioContext.sampleDmaReuseQueue2WrPos = gAudioContext.sampleDmaCount - gAudioContext.sampleDmaListSize1;
}
+// SOH [Port] Completely reworked from decomp: SAF custom fontIds can exceed the native table; bounds-check against
+// fontMapSize to avoid OOB reads.
s32 AudioLoad_IsFontLoadComplete(s32 fontId) {
- return true;
if (fontId == 0xFF) {
return true;
-
- } else if (gAudioContext.fontLoadStatus[fontId] >= 2) {
- return true;
- } else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= 2) {
+ }
+ // Resolve indirection (identity for FONT_TABLE today, but kept for parity with other tables).
+ fontId = (s32)AudioLoad_GetRealTableIndex(FONT_TABLE, (u32)fontId);
+ if ((size_t)fontId >= fontMapSize) {
+ // No entry in the font map — SAF sequence with no associated soundfont, treat as ready.
return true;
- } else {
- return false;
}
+ return gAudioContext.fontLoadStatus[fontId] >= 2;
}
s32 AudioLoad_IsSeqLoadComplete(s32 seqId) {
@@ -336,7 +337,7 @@ s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) {
}
void AudioLoad_SetFontLoadStatus(s32 fontId, s32 status) {
- if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != 5)) {
+ if ((fontId != 0xFF) && ((size_t)fontId < fontMapSize) && (gAudioContext.fontLoadStatus[fontId] != 5)) {
gAudioContext.fontLoadStatus[fontId] = status;
}
}