]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/strconv.cpp
Help text for regions
[wxWidgets.git] / src / common / strconv.cpp
index 4e62a144b1f028891048d082b4fc123ab8369176..49e78f40dd9f71f28129782099c729b9d39523cb 100644 (file)
@@ -425,13 +425,9 @@ wxMBConv::cWC2MB(const wchar_t *inBuff, size_t inLen, size_t *outLen) const
     size_t dstLen = FromWChar(NULL, 0, inBuff, inLen);
     if ( dstLen != wxCONV_FAILED )
     {
-        if ( !dstLen )
-        {
-            // special case: can't allocate 0 size buffer below
-            dstLen++;
-        }
-
-        wxCharBuffer buf(dstLen - 1);
+        // special case of empty input: can't allocate 0 size buffer below as
+        // wxCharBuffer insists on NUL-terminating it
+        wxCharBuffer buf(dstLen ? dstLen - 1 : 1);
         if ( FromWChar(buf.data(), dstLen, inBuff, inLen) != wxCONV_FAILED )
         {
             if ( outLen )
@@ -2001,6 +1997,7 @@ public:
     }
 
     wxMBConv_win32(const wxMBConv_win32& conv)
+        : wxMBConv()
     {
         m_CodePage = conv.m_CodePage;
         m_minMBCharWidth = conv.m_minMBCharWidth;