summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-18 22:22:56 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-18 23:10:50 +0300
commit9fbbdc2ce4d7d7a9551d59bb45f0d95ac33c4a2a (patch)
tree44086ebd4f4d66bc28856ffbf15a7b6a74dbeeb1 /src/resources
parent8b3be62d63cac102aa8b0d30feeb1751b64afb7a (diff)
downloadmanaverse-9fbbdc2ce4d7d7a9551d59bb45f0d95ac33c4a2a.tar.gz
manaverse-9fbbdc2ce4d7d7a9551d59bb45f0d95ac33c4a2a.tar.bz2
manaverse-9fbbdc2ce4d7d7a9551d59bb45f0d95ac33c4a2a.tar.xz
manaverse-9fbbdc2ce4d7d7a9551d59bb45f0d95ac33c4a2a.zip
Fix memory corruption with SDL_mixer < 1.2.12 (SDL 1.2).
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/sdlmusic.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/resources/sdlmusic.cpp b/src/resources/sdlmusic.cpp
index c2a51aaf4..964cab507 100644
--- a/src/resources/sdlmusic.cpp
+++ b/src/resources/sdlmusic.cpp
@@ -24,6 +24,13 @@
#include "debug.h"
+#define SDL_MIXER_COMPILEDVERSION \
+ SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, \
+ SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL)
+
+#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \
+ (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
+
SDLMusic::SDLMusic(Mix_Music *const music,
SDL_RWops *const rw,
const std::string &name) :
@@ -38,11 +45,13 @@ SDLMusic::~SDLMusic()
{
Mix_FreeMusic(mMusic);
#ifndef USE_SDL2
+#if SDL_MIXER_VERSION_ATLEAST(1, 2, 12)
if (mRw)
{
SDL_RWclose(mRw);
mRw = nullptr;
}
+#endif // SDL_MIXER_VERSION_ATLEAST(1, 2, 12)
#endif // USE_SDL2
}