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.
This commit is contained in:
Mathieu Eyraud 2024-06-04 13:50:27 +02:00 committed by Sam Lantinga
parent 470cfc2755
commit c226630086
1 changed files with 2 additions and 2 deletions

View File

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