17 May 03:24
[PATCH 2/2] kernel32: Avoid calling MultiByteToWideChar with invalid parameters
Alex Henrie <alexhenrie24 <at> gmail.com>
2012-05-17 01:24:07 GMT
2012-05-17 01:24:07 GMT
---
dlls/kernel32/locale.c | 57 +++++++++++++++++++++++++++++++----------------
1 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index b73f9b3..2970856 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -2893,34 +2893,51 @@ INT WINAPI CompareStringA(LCID lcid, DWORD style,
if (!(style & LOCALE_USE_CP_ACP)) locale_cp = get_lcid_codepage( lcid );
- len1W = MultiByteToWideChar(locale_cp, 0, str1, len1, buf1W, 130);
- if (len1W)
- str1W = buf1W;
- else
+ if (len1)
{
- len1W = MultiByteToWideChar(locale_cp, 0, str1, len1, NULL, 0);
- str1W = HeapAlloc(GetProcessHeap(), 0, len1W * sizeof(WCHAR));
- if (!str1W)
+ len1W = MultiByteToWideChar(locale_cp, 0, str1, len1, buf1W, 130);
+ if (len1W)
+ str1W = buf1W;
+ else
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return 0;
+ len1W = MultiByteToWideChar(locale_cp, 0, str1, len1, NULL, 0);
+ str1W = HeapAlloc(GetProcessHeap(), 0, len1W * sizeof(WCHAR));
(Continue reading)
RSS Feed