From 9968f7b4cd6752ead5744d4895ed392458d83abd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 21 Dec 2008 02:57:06 +0000 Subject: [PATCH] really fix the length of the string returned by wxConvertStringToOle() (#10056) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57464 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/ole/oleutils.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/msw/ole/oleutils.cpp b/src/msw/ole/oleutils.cpp index 59f387426c..94f134a097 100644 --- a/src/msw/ole/oleutils.cpp +++ b/src/msw/ole/oleutils.cpp @@ -86,12 +86,13 @@ WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr) wxString str(bStr, len); #else 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 */) ) + if (len) { - str.clear(); + wxStringBufferLength buf(str, len); // asserts if len == 0 + buf.SetLength(WideCharToMultiByte(CP_ACP, 0 /* no flags */, + bStr, len /* not necessarily NUL-terminated */, + buf, len, + NULL, NULL /* no default char */)); } #endif