Fixed memory leak when SDL_Init() was called multiple times

This commit is contained in:
Sam Lantinga 2024-07-27 09:06:52 -07:00
parent 623a90c47d
commit 218e45247f

View File

@ -450,17 +450,19 @@ char *SDL_GetPrefPath(const char *org, const char *app)
void SDL_InitFilesystem(void)
{
CachedBasePath = NULL; // just in case.
SDL_zeroa(CachedUserFolders);
}
void SDL_QuitFilesystem(void)
{
SDL_free(CachedBasePath);
CachedBasePath = NULL;
if (CachedBasePath) {
SDL_free(CachedBasePath);
CachedBasePath = NULL;
}
for (int i = 0; i < SDL_arraysize(CachedUserFolders); i++) {
SDL_free(CachedUserFolders[i]);
CachedUserFolders[i] = NULL;
if (CachedUserFolders[i]) {
SDL_free(CachedUserFolders[i]);
CachedUserFolders[i] = NULL;
}
}
}