Fixed bug in SDL_strcasecmp() with strings of different sizes

This commit is contained in:
Sam Lantinga 2012-12-22 16:52:33 -08:00
parent f1d2b88a2f
commit acdd875c64

View file

@ -858,9 +858,13 @@ SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen)
++str2;
--maxlen;
}
a = SDL_tolower((unsigned char) *str1);
b = SDL_tolower((unsigned char) *str2);
return (int) ((unsigned char) a - (unsigned char) b);
if (maxlen == 0) {
return 0;
} else {
a = SDL_tolower((unsigned char) *str1);
b = SDL_tolower((unsigned char) *str2);
return (int) ((unsigned char) a - (unsigned char) b);
}
}
#endif