Add trailing path separator to SDL_GetUserFolder()

This commit is contained in:
Semphris
2024-04-30 16:57:17 -04:00
committed by Sam Lantinga
parent 97d0e78842
commit b9d3d746a0
8 changed files with 74 additions and 15 deletions

View File

@@ -97,7 +97,18 @@ char *SDL_GetUserFolder(SDL_Folder folder)
return NULL;
}
return SDL_strdup(home);
char *retval = SDL_malloc(SDL_strlen(home) + 2);
if (!retval) {
return NULL;
}
if (SDL_snprintf(retval, SDL_strlen(home) + 2, "%s/", home) < 0) {
SDL_SetError("Couldn't snprintf home path for Emscripten: %s", home);
SDL_free(retval);
return NULL;
}
return retval;
}
#endif /* SDL_FILESYSTEM_EMSCRIPTEN */