From ca9e9cc3c5405562af7b8de6082536a4382e9941 Mon Sep 17 00:00:00 2001
From: tatyana <tatyana@etersoft.ru>
Date: Sat, 30 Mar 2013 12:09:32 +0400
Subject: [PATCH 2/2] kernel32: MBTWC calling with StaticUnicodeBuffer only if
 size of strings <= 130(eterbug #8821)

---
 dlls/kernel32/locale.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 0793378..00ddcb0 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -3008,9 +3008,12 @@ INT WINAPI CompareStringA(LCID lcid, DWORD flags,
 
     if (len1)
     {
-        len1W = MultiByteToWideChar(locale_cp, 0, str1, len1, buf1W, 130);
-        if (len1W)
-            str1W = buf1W;
+        if (len1 <= 130)
+        {
+            len1W = MultiByteToWideChar(locale_cp, 0, str1, len1, buf1W, 130);
+            if (len1W)
+                str1W = buf1W;
+        }
         else
         {
             len1W = MultiByteToWideChar(locale_cp, 0, str1, len1, NULL, 0);
@@ -3031,9 +3034,12 @@ INT WINAPI CompareStringA(LCID lcid, DWORD flags,
 
     if (len2)
     {
-        len2W = MultiByteToWideChar(locale_cp, 0, str2, len2, buf2W, 130);
-        if (len2W)
-            str2W = buf2W;
+        if (len2 <= 130)
+        {
+            len2W = MultiByteToWideChar(locale_cp, 0, str2, len2, buf2W, 130);
+            if (len2W)
+                str2W = buf2W;
+        }
         else
         {
             len2W = MultiByteToWideChar(locale_cp, 0, str2, len2, NULL, 0);
-- 
1.8.1.4
