| Summary: | Memory leak issue in SDL_mixer-1.2.12/music.c file | ||
|---|---|---|---|
| Product: | SDL_mixer | Reporter: | Nitz <nitin.j4> |
| Component: | misc | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 1.2.12 | ||
| Hardware: | x86 | ||
| OS: | Linux | ||
Fixed, thanks! |
Mix_Music *Mix_LoadMUSType_RW(SDL_RWops *rw, Mix_MusicType type, int freesrc) { // SOME CODE /* Allocate memory for the music structure */ music = (Mix_Music *)SDL_malloc(sizeof(Mix_Music)); if (music == NULL ) { Mix_SetError("Out of memory"); return NULL; } music->error = 0; switch (type) { #ifdef WAV_MUSIC case MUS_WAV: /* The WAVE loader needs the first 4 bytes of the header */ { Uint8 magic[5]; int start = SDL_RWtell(rw); if (SDL_RWread(rw, magic, 1, 4) != 4) { Mix_SetError("Couldn't read from RWops"); SDL_free(music); // This line is added return MUS_NONE; } // SOME CODE } In this code 'music' is dynamically allocated. But memory get leaked at return MUS_NONE. So it is important to free the 'music'. Patch is added in the above code with the comment // This line is added. Thanks & Regards, Nitz