From 4d2912d6003b53688e05923d94b58b557be841dd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 25 Oct 2002 00:15:05 +0000 Subject: [PATCH] fix for conversion buffer size problems git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17628 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/string.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/string.cpp b/src/common/string.cpp index 3ca72d8e68..5475133576 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -251,7 +251,8 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength) return; } - if ( conv.MB2WC(m_pchData, psz, nLen) != (size_t)-1 ) + // MB2WC wants the buffer size, not the string length + if ( conv.MB2WC(m_pchData, psz, nLen + 1) != (size_t)-1 ) { // initialized ok return; @@ -290,7 +291,8 @@ wxString::wxString(const wchar_t *pwz, wxMBConv& conv, size_t nLength) return; } - if ( conv.WC2MB(m_pchData, pwz, nLen) != (size_t)-1 ) + // WC2MB wants the buffer size, not the string length + if ( conv.WC2MB(m_pchData, pwz, nLen + 1) != (size_t)-1 ) { // initialized ok return;