diff --git a/src/filesystem/posix/SDL_sysfsops.c b/src/filesystem/posix/SDL_sysfsops.c index 015b8d4b5a..127ef0f86c 100644 --- a/src/filesystem/posix/SDL_sysfsops.c +++ b/src/filesystem/posix/SDL_sysfsops.c @@ -45,7 +45,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 9c48ba957b..a6f99973ed 100644 --- a/src/filesystem/windows/SDL_sysfsops.c +++ b/src/filesystem/windows/SDL_sysfsops.c @@ -53,7 +53,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] = '\\';