Mix_InitMP3: unload dll if mpg123_init() fails. SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Sat, 13 Oct 2018 23:02:04 +0300
branchSDL-1.2
changeset 9086b860486ce24
parent 907 f4c576887ec3
child 909 d37b598f128d
Mix_InitMP3: unload dll if mpg123_init() fails.
dynamic_mp3.c
     1.1 --- a/dynamic_mp3.c	Sat Oct 13 22:20:22 2018 +0300
     1.2 +++ b/dynamic_mp3.c	Sat Oct 13 23:02:04 2018 +0300
     1.3 @@ -32,7 +32,7 @@
     1.4  #ifdef MPG123_DYNAMIC
     1.5  #define FUNCTION_LOADER(FUNC, SIG) \
     1.6  	mpg123.FUNC = (SIG) SDL_LoadFunction(mpg123.handle, #FUNC); \
     1.7 -	if (mpg123.FUNC == NULL) { SDL_UnloadObject(mpg123.handle); return -1; }
     1.8 +	if (mpg123.FUNC == NULL) { goto initerr; }
     1.9  #else
    1.10  #define FUNCTION_LOADER(FUNC, SIG) \
    1.11  	mpg123.FUNC = FUNC;
    1.12 @@ -63,6 +63,10 @@
    1.13  		FUNCTION_LOADER(mpg123_seek, off_t (*)( mpg123_handle *mh, off_t sampleoff, int whence ))
    1.14  		FUNCTION_LOADER(mpg123_strerror, const char* (*)(mpg123_handle *mh))
    1.15  		if (mpg123.mpg123_init() != MPG123_OK) {
    1.16 +#ifdef MPG123_DYNAMIC
    1.17 +			initerr:
    1.18 +			SDL_UnloadObject(mpg123.handle);
    1.19 +#endif
    1.20  			return -1;
    1.21  		}
    1.22  	}