Просмотр исходного кода

Fix SDL_EnumerateDirectory(/) failing on POSIX and Windows.

Edgar J San Martin 2 месяцев назад
Родитель
Сommit
09a2283b53
2 измененных файлов с 2 добавлено и 2 удалено
  1. 1 1
      src/filesystem/posix/SDL_sysfsops.c
  2. 1 1
      src/filesystem/windows/SDL_sysfsops.c

+ 1 - 1
src/filesystem/posix/SDL_sysfsops.c

@@ -85,7 +85,7 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
 
     // trim down to a single path separator at the end, in case the caller added one or more.
     pathwithseplen--;
-    while ((pathwithseplen >= 0) && (pathwithsep[pathwithseplen] == '/')) {
+    while ((pathwithseplen > 0) && (pathwithsep[pathwithseplen] == '/')) {
         pathwithsep[pathwithseplen--] = '\0';
     }
 

+ 1 - 1
src/filesystem/windows/SDL_sysfsops.c

@@ -57,7 +57,7 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
 
         // trim down to a single path separator at the end, in case the caller added one or more.
         patternlen--;
-        while ((patternlen >= 0) && ((pattern[patternlen] == '\\') || (pattern[patternlen] == '/'))) {
+        while ((patternlen > 0) && ((pattern[patternlen] == '\\') || (pattern[patternlen] == '/'))) {
             pattern[patternlen--] ='\0';
         }
         pattern[++patternlen] = '\\';