Author: akhaldi
Date: Sat Jun 6 12:25:23 2015
New Revision: 68034
URL:
http://svn.reactos.org/svn/reactos?rev=68034&view=rev
Log:
[KERNEL32] Apply Wine commit 80695cd by Akihiro Sagawa: Return correct buffer size when
returning DBCS characters. CORE-9246
Modified:
trunk/reactos/dll/win32/kernel32/winnls/string/lcformat.c
Modified: trunk/reactos/dll/win32/kernel32/winnls/string/lcformat.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/winnls/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/winnls/string/lcformat.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/winnls/string/lcformat.c [iso-8859-1] Sat Jun 6
12:25:23 2015
@@ -2084,7 +2084,7 @@
int WINAPI GetCalendarInfoA(LCID lcid, CALID Calendar, CALTYPE CalType,
LPSTR lpCalData, int cchData, LPDWORD lpValue)
{
- int ret;
+ int ret, cchDataW = cchData;
LPWSTR lpCalDataW = NULL;
if (NLS_IsUnicodeOnlyLcid(lcid))
@@ -2093,13 +2093,14 @@
return 0;
}
- if (cchData &&
- !(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchData*sizeof(WCHAR))))
- return 0;
-
- ret = GetCalendarInfoW(lcid, Calendar, CalType, lpCalDataW, cchData, lpValue);
+ if (!cchData && !(CalType & CAL_RETURN_NUMBER))
+ cchDataW = GetCalendarInfoW(lcid, Calendar, CalType, NULL, 0, NULL);
+ if (!(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchDataW*sizeof(WCHAR))))
+ return 0;
+
+ ret = GetCalendarInfoW(lcid, Calendar, CalType, lpCalDataW, cchDataW, lpValue);
if(ret && lpCalDataW && lpCalData)
- WideCharToMultiByte(CP_ACP, 0, lpCalDataW, -1, lpCalData, cchData, NULL, NULL);
+ ret = WideCharToMultiByte(CP_ACP, 0, lpCalDataW, -1, lpCalData, cchData, NULL,
NULL);
else if (CalType & CAL_RETURN_NUMBER)
ret *= sizeof(WCHAR);
HeapFree(GetProcessHeap(), 0, lpCalDataW);