Fix the crashing bug hopefully

A value of 1 in freesrc for Mix_LoadWAV_RW and Mix_LoadMus_RW calls SDL_RWclose on the RWops anyway.
For Mix_LoadWAV_RW the RWops is freed right after the data is loaded (because it makes a copy of the data in memory)
For Mix_LoadMUS_RW the RWops is freed when Mix_FreeMusic is called (because the data is not a copy)
So setting 1 on freesrc doesn't actually free the RWops immediately on Mix_LoadMus_RW *unless* it failed to load any music.
This commit is contained in:
Sryder 2018-10-07 10:37:45 +01:00
parent 02597e0bf9
commit fb6c329870

View file

@ -392,7 +392,6 @@ void *I_GetSfx(sfxinfo_t *sfx)
if (rw != NULL)
{
chunk = Mix_LoadWAV_RW(rw, 1);
SDL_RWclose(rw);
return chunk;
}
@ -663,8 +662,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
rw = SDL_RWFromMem(data, len);
if (rw != NULL)
{
music = Mix_LoadMUS_RW(rw, SDL_FALSE);
SDL_RWclose(rw);
music = Mix_LoadMUS_RW(rw, 1);
}
if (!music)
{
@ -831,8 +829,7 @@ INT32 I_RegisterSong(void *data, size_t len)
SDL_RWops *rw = SDL_RWFromMem(data, len);
if (rw != NULL)
{
music = Mix_LoadMUS_RW(rw, SDL_FALSE);
SDL_RWclose(rw);
music = Mix_LoadMUS_RW(rw, 1);
}
if (!music)
{