diff --git a/src/audio/audio_heap.c b/src/audio/audio_heap.c index dbc37c57..b1e0cb49 100644 --- a/src/audio/audio_heap.c +++ b/src/audio/audio_heap.c @@ -991,16 +991,14 @@ void AudioHeap_DiscardSampleCaches(void) { Instrument* instrument; SampleCacheEntry* entry; -#ifdef AVOID_UB - entry = gPersistentSampleCache.entries; -#endif - for (fontId = 0; fontId < numFonts; fontId++) { sampleBankId1 = gSoundFontList[fontId].sampleBankId1; sampleBankId2 = gSoundFontList[fontId].sampleBankId2; - if (((sampleBankId1 != SAMPLES_NONE_U) && (entry->sampleBankId == sampleBankId1)) || - ((sampleBankId2 != SAMPLES_NONE) && (entry->sampleBankId == sampleBankId2)) || - (entry->sampleBankId == SAMPLES_SFX)) { + // @port: avoid reading from garbage memory, + // F-Zero X newer version of this audio driver has this fix: + if (((sampleBankId1 != SAMPLES_NONE_U) /* && (entry->sampleBankId == sampleBankId1) */) || + ((sampleBankId2 != SAMPLES_NONE) /* && (entry->sampleBankId == sampleBankId2)*/ ) /* || + (entry->sampleBankId == SAMPLES_SFX) */) { if (((void*) AudioHeap_SearchCaches(FONT_TABLE, CACHE_PERMANENT, fontId) != NULL) && ((gFontLoadStatus[fontId] > 1) != 0)) { for (i = 0; i < gPersistentSampleCache.numEntries; i++) {