Fixed bug 3115 - Double free or corruption when playing some MS ADPCM files
authorSam Lantinga <slouken@libsdl.org>
Thu, 12 Oct 2017 22:48:19 -0700
changeset 760b94b48c76c69
parent 759 e95ad142dfd6
child 761 2c0a45f9a767
Fixed bug 3115 - Double free or corruption when playing some MS ADPCM files

Vikas

Source SDL_RWops should be deleted in Mix_LoadMUSType_RW() and not in WAVStream_LoadSong_RW.

To fix this, we can have two approaches:
1. Instead of calling WAVStream_FreeSong(wave), call SDL_free(wave), As it was happening in previous version
-> Patch attached for latest revision(#1aca2b6d570f)

2. Before calling WAVStream_FreeSong(wave), set wave->freesrc to 0
if (!loaded) {
wave->freesrc = 0; // Newly added line
WAVStream_FreeSong(wave);
return(NULL);
}
wavestream.c
     1.1 --- a/wavestream.c	Thu Oct 12 22:27:09 2017 -0700
     1.2 +++ b/wavestream.c	Thu Oct 12 22:48:19 2017 -0700
     1.3 @@ -156,7 +156,7 @@
     1.4              Mix_SetError("Unknown WAVE format");
     1.5          }
     1.6          if (!loaded) {
     1.7 -            WAVStream_FreeSong(wave);
     1.8 +            SDL_free(wave);
     1.9              return(NULL);
    1.10          }
    1.11          SDL_BuildAudioCVT(&wave->cvt,