From acdd875c64a233f1018143675b1f0cf7acc3643f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 22 Dec 2012 16:52:33 -0800 Subject: [PATCH] Fixed bug in SDL_strcasecmp() with strings of different sizes --- src/stdlib/SDL_string.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index b8536e81e..1a5e3422b 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -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