Commit 3a475120 authored by Vincent Béron's avatar Vincent Béron Committed by Alexandre Julliard

Correct some allocated buffer lengths while converting to Unicode.

parent e9310da5
...@@ -344,15 +344,14 @@ static void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, NEWTEXTMETRIC ...@@ -344,15 +344,14 @@ static void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, NEWTEXTMETRIC
/*********************************************************************** /***********************************************************************
* FONT_mbtowc * FONT_mbtowc
* *
* Returns a '\0' terminated Unicode translation of str using the * Returns a Unicode translation of str using the charset of the
* charset of the currently selected font in hdc. If count is -1 then * currently selected font in hdc. If count is -1 then str is assumed
* str is assumed to be '\0' terminated, otherwise it contains the * to be '\0' terminated, otherwise it contains the number of bytes to
* number of bytes to convert. If plenW is non-NULL, on return it * convert. If plenW is non-NULL, on return it will point to the
* will point to the number of WCHARs (excluding the '\0') that have * number of WCHARs that have been written. If pCP is non-NULL, on
* been written. If pCP is non-NULL, on return it will point to the * return it will point to the codepage used in the conversion. The
* codepage used in the conversion. * caller should free the returned LPWSTR from the process heap
* The caller should free the returned LPWSTR from the process * itself.
* heap itself.
*/ */
static LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP) static LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP)
{ {
...@@ -401,9 +400,8 @@ static LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP) ...@@ -401,9 +400,8 @@ static LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP)
if(count == -1) count = strlen(str); if(count == -1) count = strlen(str);
lenW = MultiByteToWideChar(cp, 0, str, count, NULL, 0); lenW = MultiByteToWideChar(cp, 0, str, count, NULL, 0);
strW = HeapAlloc(GetProcessHeap(), 0, (lenW + 1) * sizeof(WCHAR)); strW = HeapAlloc(GetProcessHeap(), 0, lenW*sizeof(WCHAR));
MultiByteToWideChar(cp, 0, str, count, strW, lenW); MultiByteToWideChar(cp, 0, str, count, strW, lenW);
strW[lenW] = '\0';
TRACE("mapped %s -> %s\n", debugstr_an(str, count), debugstr_wn(strW, lenW)); TRACE("mapped %s -> %s\n", debugstr_an(str, count), debugstr_wn(strW, lenW));
if(plenW) *plenW = lenW; if(plenW) *plenW = lenW;
if(pCP) *pCP = cp; if(pCP) *pCP = cp;
......
...@@ -111,7 +111,7 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD data) ...@@ -111,7 +111,7 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD data)
{ {
DWORD len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 ); DWORD len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
wfile = HeapAlloc( GetProcessHeap(), 0, (len+1) * sizeof(WCHAR)); wfile = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR));
MultiByteToWideChar( CP_ACP, 0, filename, -1, wfile, len ); MultiByteToWideChar( CP_ACP, 0, filename, -1, wfile, len );
} }
......
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