Browse Source

Fix memory leak in SDL_IOFromFile()

If Android_JNI_FileOpen() or windows_file_open() fail, SDL_CloseIO(iostr) does nothing because 'iostr' is NULL and 'iodata' is leaked.
Mathieu Eyraud 1 year ago
parent
commit
c226630086
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/file/SDL_iostream.c

+ 2 - 2
src/file/SDL_iostream.c

@@ -600,7 +600,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
 
     void *iodata = NULL;
     if (Android_JNI_FileOpen(&iodata, file, mode) < 0) {
-        SDL_CloseIO(iostr);
+        Android_JNI_FileClose(iodata);
         return NULL;
     }
 
@@ -629,7 +629,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
     }
 
     if (windows_file_open(iodata, file, mode) < 0) {
-        SDL_CloseIO(iostr);
+        windows_file_close(iodata);
         return NULL;
     }