diff --git a/binding/filesystem-binding.cpp b/binding/filesystem-binding.cpp index 0e33333e0..4b9e8cb81 100644 --- a/binding/filesystem-binding.cpp +++ b/binding/filesystem-binding.cpp @@ -39,10 +39,13 @@ #include #endif +#include "debugwriter.h" + static void fileIntFreeInstance(void *inst) { SDL_IOStream *ops = static_cast(inst); - SDL_CloseIO(ops); + if (ops) // if we aren't closed already + SDL_CloseIO(ops); } #if RAPI_FULL > 187 @@ -130,6 +133,7 @@ RB_METHOD(fileIntClose) { SDL_IOStream *ops = getPrivateData(self); SDL_CloseIO(ops); + setPrivateData(self, NULL); // mark as closed return Qnil; }