Skip to content

Commit

Permalink
music_pxtone.cpp: fix RWops leak
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-sloth committed Jan 26, 2025
1 parent 32ce881 commit 981c1c7
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/codecs/music_pxtone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ static void PXTONE_SetDefault(PXTONE_Setup *setup)
/* This file supports PXTONE music streams */
typedef struct
{
SDL_RWops *src;
Sint64 src_start;
int freesrc;

int volume;
int volume_real;
double tempo;
Expand Down Expand Up @@ -251,7 +247,6 @@ static void *PXTONE_NewRWex(struct SDL_RWops *src, int freesrc, const char *args
}

/* Attempt to load metadata */
music->freesrc = freesrc;

name = music->pxtn->text->get_name_buf(&name_len);
if (name) {
Expand All @@ -267,6 +262,11 @@ static void *PXTONE_NewRWex(struct SDL_RWops *src, int freesrc, const char *args
SDL_free(temp_string);
}

/* release RWops now, since it's already fully loaded to pxtn */
if (freesrc) {
SDL_RWclose(src);
}

return music;
}

Expand Down Expand Up @@ -298,9 +298,6 @@ static void PXTONE_Delete(void *context)
SDL_free(music->buffer);
}

if (music->src && music->freesrc) {
SDL_RWclose(music->src);
}
SDL_free(music);
}
}
Expand Down

0 comments on commit 981c1c7

Please sign in to comment.