aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2010-06-24 06:46:03 +0000
committernyamatongwe <unknown>2010-06-24 06:46:03 +0000
commitc9672172dc7d26fb18098976863e83dd60e46760 (patch)
treeb4f99d040abf1ce8b28a3abe2fcbb734a9a5022b
parent0bb9b5b758c3cacd021ba14a0d1d692c708daeab (diff)
downloadscintilla-mirror-c9672172dc7d26fb18098976863e83dd60e46760.tar.gz
Protect against bad UTF-8 when case folding.
-rw-r--r--win32/ScintillaWin.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index ce959f893..31a7a0ab5 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1314,6 +1314,12 @@ public:
size_t nUtf16Mixed = ::MultiByteToWideChar(65001, 0, mixed, lenMixed,
&utf16Mixed[0], utf16Mixed.size());
+ if (nUtf16Mixed == 0) {
+ // Failed to convert -> bad UTF-8
+ folded[0] = '\0';
+ return 1;
+ }
+
if (nUtf16Mixed * 4 > utf16Folded.size()) { // Maximum folding expansion factor of 4
utf16Folded.resize(nUtf16Mixed * 4 + 8);
}