Skip to content

Commit

Permalink
Mix_InitMP3: unload dll if mpg123_init() fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Oct 13, 2018
1 parent 9aecbd8 commit 3fcb2cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dynamic_mp3.c
Expand Up @@ -32,7 +32,7 @@ mpg123_loader mpg123 = {
#ifdef MPG123_DYNAMIC
#define FUNCTION_LOADER(FUNC, SIG) \
mpg123.FUNC = (SIG) SDL_LoadFunction(mpg123.handle, #FUNC); \
if (mpg123.FUNC == NULL) { SDL_UnloadObject(mpg123.handle); return -1; }
if (mpg123.FUNC == NULL) { goto initerr; }
#else
#define FUNCTION_LOADER(FUNC, SIG) \
mpg123.FUNC = FUNC;
Expand Down Expand Up @@ -63,6 +63,10 @@ int Mix_InitMP3(void)
FUNCTION_LOADER(mpg123_seek, off_t (*)( mpg123_handle *mh, off_t sampleoff, int whence ))
FUNCTION_LOADER(mpg123_strerror, const char* (*)(mpg123_handle *mh))
if (mpg123.mpg123_init() != MPG123_OK) {
#ifdef MPG123_DYNAMIC
initerr:
SDL_UnloadObject(mpg123.handle);
#endif
return -1;
}
}
Expand Down

0 comments on commit 3fcb2cb

Please sign in to comment.