Skip to content

Commit

Permalink
music_mpg123.c: Fixed memory access after free
Browse files Browse the repository at this point in the history
Accessing the `music->handle` after MPEG123_Delete(music) will lead to crash
  • Loading branch information
Wohlstand authored and sezero committed Jan 25, 2022
1 parent 9e49934 commit 8df5ea8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/codecs/music_mpg123.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ static void *MPG123_CreateFromRW(SDL_RWops *src, int freesrc)
rwops_read, rwops_seek, rwops_cleanup
);
if (result != MPG123_OK) {
MPG123_Delete(music);
Mix_SetError("mpg123_replace_reader_handle: %s", mpg_err(music->handle, result));
MPG123_Delete(music);
return NULL;
}

result = mpg123.mpg123_format_none(music->handle);
if (result != MPG123_OK) {
MPG123_Delete(music);
Mix_SetError("mpg123_format_none: %s", mpg_err(music->handle, result));
MPG123_Delete(music);
return NULL;
}

Expand All @@ -290,15 +290,15 @@ static void *MPG123_CreateFromRW(SDL_RWops *src, int freesrc)

result = mpg123.mpg123_open_handle(music->handle, &music->mp3file);
if (result != MPG123_OK) {
MPG123_Delete(music);
Mix_SetError("mpg123_open_handle: %s", mpg_err(music->handle, result));
MPG123_Delete(music);
return NULL;
}

result = mpg123.mpg123_getformat(music->handle, &rate, &channels, &encoding);
if (result != MPG123_OK) {
MPG123_Delete(music);
Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result));
MPG123_Delete(music);
return NULL;
}
#ifdef DEBUG_MPG123
Expand Down

0 comments on commit 8df5ea8

Please sign in to comment.