From 59af032ab6816a5cefb907a9f12c6b766a71af7c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 4 Feb 2008 08:08:57 +0000 Subject: [PATCH] use BSTR length to also deal with NULs inside BSTRs correctly in Unicode build git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51542 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/ole/oleutils.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/msw/ole/oleutils.cpp b/src/msw/ole/oleutils.cpp index c596c2bc1c..e23617df25 100644 --- a/src/msw/ole/oleutils.cpp +++ b/src/msw/ole/oleutils.cpp @@ -80,19 +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 wxString str; - const int len = SysStringLen(bStr) + 1; if ( !::WideCharToMultiByte(CP_ACP, 0 /* no flags */, - bStr, len, + bStr, len + 1 /* include last NUL */, wxStringBuffer(str, len), len, NULL, NULL /* no default char */) ) { str.clear(); } #endif + return str; }