]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/ole/oleutils.cpp
don't ask for bounding rectangle of a hidden root, this fixes a crash introduced...
[wxWidgets.git] / src / msw / ole / oleutils.cpp
index 8fbcf998855b1d38a7e678c6fb72290a24187300..59f387426c88a9f981723a2f2d61246220d0b669 100644 (file)
@@ -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;
 }