From: Václav Slavík Date: Sun, 11 Apr 2004 09:47:31 +0000 (+0000) Subject: fixed wxMBConv::cMB2WC and cWC2MB to check for conversion failure X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/635f33ceddd0c7804fe508dcfb0407a153be1ac8 fixed wxMBConv::cMB2WC and cWC2MB to check for conversion failure git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26702 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 4b2a491e13..9612c11ca9 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -177,9 +177,11 @@ const wxWCharBuffer wxMBConv::cMB2WC(const char *psz) const { // now do the actual conversion wxWCharBuffer buf(nLen); - MB2WC(buf.data(), psz, nLen + 1); // with the trailing NUL - - return buf; + nLen = MB2WC(buf.data(), psz, nLen + 1); // with the trailing NULL + if ( nLen != (size_t)-1 ) + { + return buf; + } } } @@ -196,9 +198,11 @@ const wxCharBuffer wxMBConv::cWC2MB(const wchar_t *pwz) const if ( nLen != (size_t)-1 ) { wxCharBuffer buf(nLen+3); // space for a wxUint32 trailing zero - WC2MB(buf.data(), pwz, nLen + 4); - - return buf; + nLen = WC2MB(buf.data(), pwz, nLen + 4); + if ( nLen != (size_t)-1 ) + { + return buf; + } } }