From 85a617c38ad5e3dbcd67ae63b3f87f2a7aaaada1 Mon Sep 17 00:00:00 2001
From: pionere <[EMAIL REDACTED]>
Date: Sun, 12 Dec 2021 15:34:11 +0100
Subject: [PATCH] fix memory leaks in Parse* (music_wav.c)
---
src/codecs/music_wav.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/codecs/music_wav.c b/src/codecs/music_wav.c
index 8dd2a98e..edce6cd3 100644
--- a/src/codecs/music_wav.c
+++ b/src/codecs/music_wav.c
@@ -650,7 +650,7 @@ static SDL_bool ParseFMT(WAV_Music *wave, Uint32 chunk_length)
}
if (!SDL_RWread(wave->src, data, chunk_length, 1)) {
Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length);
- return SDL_FALSE;
+ goto done;
}
format = (WaveFMT *)data;
@@ -785,6 +785,7 @@ static SDL_bool ParseSMPL(WAV_Music *wave, Uint32 chunk_length)
}
if (!SDL_RWread(wave->src, data, chunk_length, 1)) {
Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length);
+ SDL_free(data);
return SDL_FALSE;
}
chunk = (SamplerChunk *)data;
@@ -835,6 +836,7 @@ static SDL_bool ParseLIST(WAV_Music *wave, Uint32 chunk_length)
if (!SDL_RWread(wave->src, data, chunk_length, 1)) {
Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length);
+ SDL_free(data);
return SDL_FALSE;
}