From f401cc6230f32b4390cf6041be22869e21bea900 Mon Sep 17 00:00:00 2001 From: Misa Date: Mon, 15 Feb 2021 19:05:01 -0800 Subject: [PATCH] Unconditionally call FILESYSTEM_freeMemory() in SoundTrack constructor Previously, it was guarded behind a check for the length, which is... I guess still perfectly fine behavior, but there's no reason to have a length check here; FILESYSTEM_freeMemory() uses SDL_free(), which does a check that the pointer passed is non-NULL (the pointer that is passed here, despite not being initialized upon declaration, is guaranteed to be initialized by FILESYSTEM_loadFileToMemory() anyway, so). --- desktop_version/src/SoundSystem.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/desktop_version/src/SoundSystem.cpp b/desktop_version/src/SoundSystem.cpp index 1096cc20..e9c9c718 100644 --- a/desktop_version/src/SoundSystem.cpp +++ b/desktop_version/src/SoundSystem.cpp @@ -35,10 +35,7 @@ SoundTrack::SoundTrack(const char* fileName) FILESYSTEM_loadFileToMemory(fileName, &mem, &length); SDL_RWops *fileIn = SDL_RWFromMem(mem, length); sound = Mix_LoadWAV_RW(fileIn, 1); - if (length) - { - FILESYSTEM_freeMemory(&mem); - } + FILESYSTEM_freeMemory(&mem); if (sound == NULL) {