SDL: SDL_InternalGlobDirectory(): keep track of pathlen and reuse it, instead of calling SDL_strlen(path)

From 93e3e8a5fe3c83c6ee21c9abc1985ec0c6aa97d7 Mon Sep 17 00:00:00 2001
From: Petar Popovic <[EMAIL REDACTED]>
Date: Sat, 7 Mar 2026 11:35:47 +0100
Subject: [PATCH] SDL_InternalGlobDirectory(): keep track of pathlen and reuse
 it, instead of calling SDL_strlen(path)

---
 src/filesystem/SDL_filesystem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/filesystem/SDL_filesystem.c b/src/filesystem/SDL_filesystem.c
index 6a3bb25afcb41..8180b18fcdbb5 100644
--- a/src/filesystem/SDL_filesystem.c
+++ b/src/filesystem/SDL_filesystem.c
@@ -382,6 +382,7 @@ char **SDL_InternalGlobDirectory(const char *path, const char *pattern, SDL_Glob
         char *ptr = &pathcpy[pathlen-1];
         while ((ptr > pathcpy) && ((*ptr == '/') || (*ptr == '\\'))) {
             *(ptr--) = '\0';
+            --pathlen;
         }
         path = pathcpy;
     }
@@ -425,7 +426,7 @@ char **SDL_InternalGlobDirectory(const char *path, const char *pattern, SDL_Glob
     data.enumerator = enumerator;
     data.getpathinfo = getpathinfo;
     data.fsuserdata = userdata;
-    data.basedirlen = *path ? (SDL_strlen(path) + 1) : 0;  // +1 for the '/' we'll be adding.
+    data.basedirlen = *path ? (pathlen + 1) : 0;  // +1 for the '/' we'll be adding.
 
 
     char **result = NULL;