storage: generic title storage allows override paths without '/' appended.

Fixes #11299.
This commit is contained in:
Ryan C. Gordon
2025-01-15 23:47:43 -05:00
parent 874c07f8de
commit 3ffb1a8cbd

View File

@@ -236,10 +236,15 @@ static const SDL_StorageInterface GENERIC_title_iface = {
static SDL_Storage *GENERIC_Title_Create(const char *override, SDL_PropertiesID props)
{
SDL_Storage *result = NULL;
char *basepath = NULL;
if (override != NULL) {
basepath = SDL_strdup(override);
// make sure override has a path separator at the end. If you're not on Windows and used '\\', that's on you.
const size_t slen = SDL_strlen(override);
const bool need_sep = (!slen || ((override[slen-1] != '/') && (override[slen-1] != '\\')));
if (SDL_asprintf(&basepath, "%s%s", override, need_sep ? "/" : "") == -1) {
return NULL;
}
} else {
const char *base = SDL_GetBasePath();
basepath = base ? SDL_strdup(base) : NULL;