From 8f99954e0151490b4dc012514860bcf8cceb0d66 Mon Sep 17 00:00:00 2001
From: Petar Popovic <[EMAIL REDACTED]>
Date: Fri, 10 Apr 2026 16:54:08 +0200
Subject: [PATCH] SDL_EnumerateDirectory(""): Don't append path separator if
path is empty
(cherry picked from commit 1db6d5381a0ff9bd6fc5d8ab2d4d5a4fea3c8f14)
---
src/filesystem/posix/SDL_sysfsops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/filesystem/posix/SDL_sysfsops.c b/src/filesystem/posix/SDL_sysfsops.c
index 1ab9f803018be..fd42876215c4c 100644
--- a/src/filesystem/posix/SDL_sysfsops.c
+++ b/src/filesystem/posix/SDL_sysfsops.c
@@ -74,7 +74,7 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
#endif
char *pathwithsep = NULL;
- int pathwithseplen = SDL_asprintf(&pathwithsep, "%s/", apath ? apath : path);
+ int pathwithseplen = SDL_asprintf(&pathwithsep, "%s%s", apath ? apath : path, (apath ? *apath : *path) ? "/" : "");
const size_t extralen = apath ? (SDL_strlen(apath) - SDL_strlen(path)) : 0;
SDL_free(apath);
if ((pathwithseplen == -1) || (!pathwithsep)) {