msxml3: Improve bstr_from_xmlCharN implementation.

This commit is contained in:
Piotr Caban 2010-07-17 14:06:53 +02:00 committed by Alexandre Julliard
parent bf263947e7
commit 7a22365674

View File

@ -158,7 +158,6 @@ static int namespacePop(saxlocator *locator)
static BSTR bstr_from_xmlCharN(const xmlChar *buf, int len) static BSTR bstr_from_xmlCharN(const xmlChar *buf, int len)
{ {
DWORD dLen; DWORD dLen;
LPWSTR str;
BSTR bstr; BSTR bstr;
if (!buf) if (!buf)
@ -166,13 +165,11 @@ static BSTR bstr_from_xmlCharN(const xmlChar *buf, int len)
dLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, NULL, 0); dLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, NULL, 0);
if(len != -1) dLen++; if(len != -1) dLen++;
str = heap_alloc(dLen * sizeof (WCHAR)); bstr = SysAllocStringLen(NULL, dLen-1);
if (!str) if (!bstr)
return NULL; return NULL;
MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, str, dLen); MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, bstr, dLen);
if(len != -1) str[dLen-1] = '\0'; if(len != -1) bstr[dLen-1] = '\0';
bstr = SysAllocString(str);
heap_free(str);
return bstr; return bstr;
} }