]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't read beyond the end of input buffer when decoding UTF-16.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 5 Nov 2011 11:23:44 +0000 (11:23 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 5 Nov 2011 11:23:44 +0000 (11:23 +0000)
wxMBConvStrictUTF8::FromWChar() didn't update the input length correctly when
encountering a surrogate while decoding UTF-16 and could read beyond the end
of the input buffer in this case.

Fix this by simply adjusting the input length when a surrogate is read.

Closes #13614.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69676 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/strconv.cpp

index 9c6299a5d3f4e7762b8536c3d6ad56ca0def812e..f6dbc341f5b31daff71766543cfaf4a6054a9c5e 100644 (file)
@@ -1145,6 +1145,8 @@ wxMBConvStrictUTF8::FromWChar(char *dst, size_t dstLen,
         {
             // skip the next char too as we decoded a surrogate
             wp++;
+            if ( srcLen != wxNO_LEN )
+                srcLen--;
         }
 #else // wchar_t is UTF-32
         code = *wp & 0x7fffffff;