Commit dfbbd55a authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

kernel32: CompareStringW should abort on the first nonmatching character to…

kernel32: CompareStringW should abort on the first nonmatching character to avoid an invalid memory access. Signed-off-by: 's avatarDmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: 's avatarSebastian Lackner <sebastian@fds-team.de> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 5c50f658
...@@ -223,6 +223,16 @@ static inline int compare_unicode_weights(int flags, const WCHAR *str1, int len1 ...@@ -223,6 +223,16 @@ static inline int compare_unicode_weights(int flags, const WCHAR *str1, int len1
len1--; len1--;
len2--; len2--;
} }
while (len1 && !*str1)
{
str1++;
len1--;
}
while (len2 && !*str2)
{
str2++;
len2--;
}
return len1 - len2; return len1 - len2;
} }
...@@ -272,6 +282,16 @@ static inline int compare_diacritic_weights(int flags, const WCHAR *str1, int le ...@@ -272,6 +282,16 @@ static inline int compare_diacritic_weights(int flags, const WCHAR *str1, int le
len1--; len1--;
len2--; len2--;
} }
while (len1 && !*str1)
{
str1++;
len1--;
}
while (len2 && !*str2)
{
str2++;
len2--;
}
return len1 - len2; return len1 - len2;
} }
...@@ -321,23 +341,24 @@ static inline int compare_case_weights(int flags, const WCHAR *str1, int len1, ...@@ -321,23 +341,24 @@ static inline int compare_case_weights(int flags, const WCHAR *str1, int len1,
len1--; len1--;
len2--; len2--;
} }
while (len1 && !*str1)
{
str1++;
len1--;
}
while (len2 && !*str2)
{
str2++;
len2--;
}
return len1 - len2; return len1 - len2;
} }
static inline int real_length(const WCHAR *str, int len)
{
while (len && !str[len - 1]) len--;
return len;
}
int wine_compare_string(int flags, const WCHAR *str1, int len1, int wine_compare_string(int flags, const WCHAR *str1, int len1,
const WCHAR *str2, int len2) const WCHAR *str2, int len2)
{ {
int ret; int ret;
len1 = real_length(str1, len1);
len2 = real_length(str2, len2);
ret = compare_unicode_weights(flags, str1, len1, str2, len2); ret = compare_unicode_weights(flags, str1, len1, str2, len2);
if (!ret) if (!ret)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment