Skip to content

Commit 7280152

Browse files
Sackzementslouken
authored andcommitted
SDL_InternalGlobDirectory(): set string length of base directory to 1, if it's just one slash
(cherry picked from commit 67ac0e5)
1 parent a703538 commit 7280152

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/filesystem/SDL_filesystem.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,15 @@ char **SDL_InternalGlobDirectory(const char *path, const char *pattern, SDL_Glob
426426
data.enumerator = enumerator;
427427
data.getpathinfo = getpathinfo;
428428
data.fsuserdata = userdata;
429-
data.basedirlen = *path ? (pathlen + 1) : 0; // +1 for the '/' we'll be adding.
430429

430+
data.basedirlen = 0;
431+
if (*path) {
432+
if (SDL_strcmp(path, "/") == 0 || SDL_strcmp(path, "\\") == 0) {
433+
data.basedirlen = 1;
434+
} else {
435+
data.basedirlen = pathlen + 1; // +1 for the '/' we'll be adding.
436+
}
437+
}
431438

432439
char **result = NULL;
433440
if (data.enumerator(path, GlobDirectoryCallback, &data, data.fsuserdata)) {

0 commit comments

Comments
 (0)