From 6a7f8b74f1c7bd6e41986ddb43b8ff331a9e3322 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sun, 29 Sep 2024 23:09:04 -0400
Subject: [PATCH] filesystem: SDL_GlobDirectory shouldn't strip final '/' if
the path is "/".
This is common on Emscripten, where the base directory is "/".
---
src/filesystem/SDL_filesystem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/filesystem/SDL_filesystem.c b/src/filesystem/SDL_filesystem.c
index 2f2b66c94a9bb..a29ae38fdda20 100644
--- a/src/filesystem/SDL_filesystem.c
+++ b/src/filesystem/SDL_filesystem.c
@@ -363,7 +363,7 @@ char **SDL_InternalGlobDirectory(const char *path, const char *pattern, SDL_Glob
// if path ends with any '/', chop them off, so we don't confuse the pattern matcher later.
char *pathcpy = NULL;
size_t pathlen = SDL_strlen(path);
- if (pathlen && (path[pathlen-1] == '/')) {
+ if ((pathlen > 1) && (path[pathlen-1] == '/')) {
pathcpy = SDL_strdup(path);
if (!pathcpy) {
return NULL;