X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/13d92ad62a669f2b418ef66f2135221c28a25866..137c8bde085d6d5b7c459902d2ea1a198ab48765:/src/common/strconv.cpp diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 4e62a144b1..ef07724797 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -19,6 +19,7 @@ #include "wx/intl.h" #include "wx/log.h" #include "wx/utils.h" + #include "wx/hashmap.h" #endif #include "wx/strconv.h" @@ -425,13 +426,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 +1998,7 @@ public: } wxMBConv_win32(const wxMBConv_win32& conv) + : wxMBConv() { m_CodePage = conv.m_CodePage; m_minMBCharWidth = conv.m_minMBCharWidth; @@ -3076,7 +3074,6 @@ void wxCSConv::SetName(const wxChar *charset) } #if wxUSE_FONTMAP -#include "wx/hashmap.h" WX_DECLARE_HASH_MAP( wxFontEncoding, wxString, wxIntegerHash, wxIntegerEqual, wxEncodingNameCache );