Fixed bug 3018 - Loading MIDI music using FluidSynth leaks memory.
authorSam Lantinga <slouken@libsdl.org>
Wed, 17 Jun 2015 00:11:41 -0700
changeset 705fe757163b8f7
parent 704 24c1fa03dca2
child 706 fb71a96dd274
Fixed bug 3018 - Loading MIDI music using FluidSynth leaks memory.

Philipp Wiesemann

There is a memory leak in fluidsynth.c and fluidsynth_loadsong_RW_internal(). The allocated temporary buffer is not deleted if fluid_player_add_mem() returns FLUID_OK.
fluidsynth.c
     1.1 --- a/fluidsynth.c	Sun Jun 14 17:49:04 2015 -0700
     1.2 +++ b/fluidsynth.c	Wed Jun 17 00:11:41 2015 -0700
     1.3 @@ -124,6 +124,7 @@
     1.4      if ((buffer = (char*) SDL_malloc(size))) {
     1.5          if(SDL_RWread(src, buffer, size, 1) == 1) {
     1.6              if (fluidsynth.fluid_player_add_mem(song->player, buffer, size) == FLUID_OK) {
     1.7 +                SDL_free(buffer);
     1.8                  return 1;
     1.9              } else {
    1.10                  Mix_SetError("FluidSynth failed to load in-memory song");