]> git.saurik.com Git - wxWidgets.git/commitdiff
use BSTR length to also deal with NULs inside BSTRs correctly in Unicode build
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 4 Feb 2008 08:08:57 +0000 (08:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 4 Feb 2008 08:08:57 +0000 (08:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51542 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/ole/oleutils.cpp

index c596c2bc1cf6ac4dbee8d48c21524a27d1d46253..e23617df25e3cbabc0fc69aeb74839e4ef6e2054 100644 (file)
@@ -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;
 }