]> git.saurik.com Git - wxWidgets.git/commitdiff
use WideCharToMultiByte() instead of wcstombs() to deal with BSTRs containing NULs...
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 4 Feb 2008 08:04:39 +0000 (08:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 4 Feb 2008 08:04:39 +0000 (08:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/ole/oleutils.cpp

index 8fbcf998855b1d38a7e678c6fb72290a24187300..c596c2bc1cf6ac4dbee8d48c21524a27d1d46253 100644 (file)
@@ -83,11 +83,15 @@ WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr)
 #if wxUSE_UNICODE
     wxString str(bStr);
 #else
-    int len = SysStringLen(bStr) + 1;
-    char    *buf = new char[len];
-    (void)wcstombs( buf, bStr, len);
-    wxString str(buf);
-    delete[] buf;
+    wxString str;
+    const int len = SysStringLen(bStr) + 1;
+    if ( !::WideCharToMultiByte(CP_ACP, 0 /* no flags */,
+                                bStr, len,
+                                wxStringBuffer(str, len), len,
+                                NULL, NULL /* no default char */) )
+    {
+        str.clear();
+    }
 #endif
     return str;
 }