Fix memory leaks in MessageViewer and audio_load (#6124)

Add destructor to MessageViewer to free allocated buffers

Free individual strings from ResourceMgr_ListFiles before freeing the array in audio_load.c
This commit is contained in:
Paul Schwabauer
2026-01-10 13:53:37 +01:00
committed by GitHub
parent c2152a8713
commit 5bbc32c2d1
4 changed files with 20 additions and 2 deletions

View File

@@ -1352,6 +1352,9 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
seqCachePolicyMap[sDat.seqNumber] = sDat.cachePolicy;
}
for (int i = 0; i < seqListSize; i++) {
free(seqList[i]);
}
free(seqList);
// 2S2H [Streamed Audio] We need to load the custom songs after the fonts because streamed songs will use a hash to
@@ -1369,6 +1372,9 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
fontMap[sf->fntIndex] = strdup(fntList[i]);
}
for (int i = 0; i < fntListSize; i++) {
free(fntList[i]);
}
free(fntList);
int customFontStart = fntListSize;
@@ -1377,6 +1383,9 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
sf->fntIndex = i;
fontMap[i] = strdup(customFntList[i - customFontStart]);
}
for (int i = 0; i < customFntListSize; i++) {
free(customFntList[i]);
}
free(customFntList);
// 2S2H Port I think we need to take use seqListSize because entry 0x7A is missing.
@@ -1432,6 +1441,9 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
seqNum++;
}
for (int i = 0; i < customSeqListSize; i++) {
free(customSeqList[i]);
}
free(customSeqList);
numFonts = fntListSize;