]> git.saurik.com Git - wxWidgets.git/commitdiff
corrected bug in wxMBConvStrictUTF8::FromWChar(): it wrote one extra NUL when used...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 1 Jun 2008 03:11:32 +0000 (03:11 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 1 Jun 2008 03:11:32 +0000 (03:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53891 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/strconv.cpp

index 102f0d82db071dc811646c92a95273d2a2f3db3e..2e887046d31286a0e049aa84f0d4a9ef1e8ab847 100644 (file)
@@ -987,7 +987,7 @@ wxMBConvStrictUTF8::FromWChar(char *dst, size_t dstLen,
 
     for ( const wchar_t *wp = src; ; wp++ )
     {
-        if ( !(srcLen == wxNO_LEN ? *wp : srcLen--) )
+        if ( !(srcLen == wxNO_LEN ? *wp : srcLen) )
         {
             // all done successfully, just add the trailing NULL if we are not
             // using explicit length
@@ -1007,6 +1007,8 @@ wxMBConvStrictUTF8::FromWChar(char *dst, size_t dstLen,
             return written;
         }
 
+        if ( srcLen != wxNO_LEN )
+            srcLen--;
 
         wxUint32 code;
 #ifdef WC_UTF16