diff --git a/src/filesystem/posix/SDL_sysfsops.c b/src/filesystem/posix/SDL_sysfsops.c index 07539ad95b..581ee2ee07 100644 --- a/src/filesystem/posix/SDL_sysfsops.c +++ b/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'; } diff --git a/src/filesystem/windows/SDL_sysfsops.c b/src/filesystem/windows/SDL_sysfsops.c index 91394ed7ee..a5756525e8 100644 --- a/src/filesystem/windows/SDL_sysfsops.c +++ b/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] = '\\';