From de25435d2d8e7c2f3e5db15b161e313a868af149 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Fri, 14 Oct 2022 17:37:00 +0300
Subject: [PATCH] music_modplug, music_xmp: clear error if optional functions
aren't found
Reference issue: https://github.com/libsdl-org/SDL_mixer/issues/407
---
src/codecs/music_modplug.c | 3 +++
src/codecs/music_xmp.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/src/codecs/music_modplug.c b/src/codecs/music_modplug.c
index aca5d5e8..b8d2936e 100644
--- a/src/codecs/music_modplug.c
+++ b/src/codecs/music_modplug.c
@@ -83,6 +83,9 @@ static int MODPLUG_Load(void)
FUNCTION_LOADER(ModPlug_GetName, const char* (*)(ModPlugFile* file))
#ifdef MODPLUG_DYNAMIC
modplug.ModPlug_Tell = (int (*)(ModPlugFile* file)) SDL_LoadFunction(modplug.handle, "ModPlug_Tell");
+ if (modplug.ModPlug_Tell == NULL) {
+ SDL_ClearError(); /* ModPlug_Tell is optional. */
+ }
#elif defined(MODPLUG_HAS_TELL)
modplug.ModPlug_Tell = ModPlug_Tell;
#else
diff --git a/src/codecs/music_xmp.c b/src/codecs/music_xmp.c
index a89f725b..cce2e6dd 100644
--- a/src/codecs/music_xmp.c
+++ b/src/codecs/music_xmp.c
@@ -99,6 +99,9 @@ static int XMP_Load(void)
FUNCTION_LOADER(xmp_free_context, void(*)(xmp_context))
#if defined(XMP_DYNAMIC)
libxmp.xmp_load_module_from_callbacks = (int (*)(xmp_context,void*,struct xmp_callbacks)) SDL_LoadFunction(libxmp.handle, "xmp_load_module_from_callbacks");
+ if (libxmp.xmp_load_module_from_callbacks == NULL) {
+ SDL_ClearError(); /* xmp_load_module_from_callbacks is optional. */
+ }
#elif (XMP_VERCODE >= 0x040500)
libxmp.xmp_load_module_from_callbacks = xmp_load_module_from_callbacks;
#else