From 041e6050fdfa232472d7505b842d845d37dcb6de Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 5 Nov 2011 11:23:44 +0000 Subject: [PATCH] Don't read beyond the end of input buffer when decoding UTF-16. 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 9c6299a5d3..f6dbc341f5 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -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; -- 2.45.2