SDL: fix buffer overrun in SDL_strncmp

Always check len first before dereferencing the pointers.
This commit is contained in:
Kawe Mazidjatari 2024-10-12 01:47:52 +02:00
parent d9432129b2
commit c0832b91d3

View File

@ -1086,7 +1086,7 @@ SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
#if defined(HAVE_STRNCMP)
return strncmp(str1, str2, maxlen);
#else
while (*str1 && *str2 && maxlen) {
while (maxlen && *str1 && *str2) {
if (*str1 != *str2)
break;
++str1;