From 9c9af253dcf7b8c1397f173ed79e3495e7a24eed Mon Sep 17 00:00:00 2001 From: ZakatTeamI2P Date: Thu, 23 Apr 2026 20:03:53 +0400 Subject: [PATCH] afg --- binding-mri/binding-mri.cpp | 1 + binding-mri/filesystem-binding.cpp | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index 0f24640..fbb1d81 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -594,3 +594,4 @@ static void mriBindingTerminate(){ static void mriBindingReset(){ rb_raise(getRbData()->exc[Reset], " "); } + diff --git a/binding-mri/filesystem-binding.cpp b/binding-mri/filesystem-binding.cpp index 6dcc7a2..41d6d93 100644 --- a/binding-mri/filesystem-binding.cpp +++ b/binding-mri/filesystem-binding.cpp @@ -30,10 +30,11 @@ #include static void fileIntFreeInstance(void *inst){ - SDL_IOStream *ops = static_cast(inst); - SDL_CloseIO(ops); + SDL_IOStream *ops = static_cast(inst); + if (ops) { + SDL_CloseIO(ops); + } } - DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance); static VALUE fileIntForPath(const char *path, bool rubyExc){ @@ -91,14 +92,15 @@ RB_METHOD(fileIntRead){ } RB_METHOD(fileIntClose){ - RB_UNUSED_PARAM; - SDL_IOStream *ops = getPrivateData(self); + RB_UNUSED_PARAM; + SDL_IOStream *ops = getPrivateData(self); if (!ops){ printf("NULL guard! fileIntClose broken!"); return Qnil; } - SDL_CloseIO(ops); - return Qnil; + SDL_CloseIO(ops); + setPrivateData(self, nullptr); + return Qnil; } RB_METHOD(fileIntGetByte){