mirror of
https://github.com/HarbourMasters/Starship
synced 2026-05-22 22:44:42 -04:00
audio UB fix correction
This commit is contained in:
+14
-4
@@ -994,15 +994,25 @@ void AudioHeap_DiscardSampleCaches(void) {
|
||||
for (fontId = 0; fontId < numFonts; fontId++) {
|
||||
sampleBankId1 = gSoundFontList[fontId].sampleBankId1;
|
||||
sampleBankId2 = gSoundFontList[fontId].sampleBankId2;
|
||||
// @port: avoid reading from garbage memory,
|
||||
#ifdef AVOID_UB
|
||||
// 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 ((sampleBankId1 != SAMPLES_NONE_U) || (sampleBankId2 != SAMPLES_NONE)) {
|
||||
#else
|
||||
//! @bug: entry is uninitialized, reading from garbage memory.
|
||||
if (((sampleBankId1 != SAMPLES_NONE_U) && (entry->sampleBankId == sampleBankId1)) ||
|
||||
((sampleBankId2 != SAMPLES_NONE) && (entry->sampleBankId == sampleBankId2)) ||
|
||||
(entry->sampleBankId == SAMPLES_SFX)) {
|
||||
#endif
|
||||
if (((void*) AudioHeap_SearchCaches(FONT_TABLE, CACHE_PERMANENT, fontId) != NULL) &&
|
||||
((gFontLoadStatus[fontId] > 1) != 0)) {
|
||||
for (i = 0; i < gPersistentSampleCache.numEntries; i++) {
|
||||
entry = &gPersistentSampleCache.entries[i];
|
||||
#ifdef AVOID_UB
|
||||
if ((sampleBankId1 != entry->sampleBankId) && (sampleBankId2 != entry->sampleBankId) &&
|
||||
(entry->sampleBankId != SAMPLES_SFX)) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
for (instId = 0; instId < gSoundFontList[fontId].numInstruments; instId++) {
|
||||
instrument = Audio_GetInstrument(fontId, instId);
|
||||
if (instrument != NULL) {
|
||||
|
||||
Reference in New Issue
Block a user