X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/795b0f144495454aac0dc23e865f7a8f87f6dfa3..4a36036eb24baac040eea64216458773c9dd6e40:/src/msw/ole/oleutils.cpp?ds=sidebyside diff --git a/src/msw/ole/oleutils.cpp b/src/msw/ole/oleutils.cpp index 8fbcf99885..59f387426c 100644 --- a/src/msw/ole/oleutils.cpp +++ b/src/msw/ole/oleutils.cpp @@ -80,15 +80,21 @@ WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr) if ( !bStr ) return wxString(); + const int len = SysStringLen(bStr); + #if wxUSE_UNICODE - wxString str(bStr); + wxString str(bStr, len); #else - int len = SysStringLen(bStr) + 1; - char *buf = new char[len]; - (void)wcstombs( buf, bStr, len); - wxString str(buf); - delete[] buf; + wxString str; + if ( !::WideCharToMultiByte(CP_ACP, 0 /* no flags */, + bStr, len /* not necessary NUL-terminated */, + wxStringBuffer(str, len + 1), len + 1, + NULL, NULL /* no default char */) ) + { + str.clear(); + } #endif + return str; }