Skip to content

Commit 09a2283

Browse files
ej-sanmartinslouken
authored andcommitted
Fix SDL_EnumerateDirectory(/) failing on POSIX and Windows.
1 parent 6665eba commit 09a2283

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/filesystem/posix/SDL_sysfsops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
8585

8686
// trim down to a single path separator at the end, in case the caller added one or more.
8787
pathwithseplen--;
88-
while ((pathwithseplen >= 0) && (pathwithsep[pathwithseplen] == '/')) {
88+
while ((pathwithseplen > 0) && (pathwithsep[pathwithseplen] == '/')) {
8989
pathwithsep[pathwithseplen--] = '\0';
9090
}
9191

src/filesystem/windows/SDL_sysfsops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
5757

5858
// trim down to a single path separator at the end, in case the caller added one or more.
5959
patternlen--;
60-
while ((patternlen >= 0) && ((pattern[patternlen] == '\\') || (pattern[patternlen] == '/'))) {
60+
while ((patternlen > 0) && ((pattern[patternlen] == '\\') || (pattern[patternlen] == '/'))) {
6161
pattern[patternlen--] ='\0';
6262
}
6363
pattern[++patternlen] = '\\';

0 commit comments

Comments
 (0)