diff options
author | nyamatongwe <unknown> | 2012-03-21 23:39:03 +1100 |
---|---|---|
committer | nyamatongwe <unknown> | 2012-03-21 23:39:03 +1100 |
commit | fa832504c217fa68b9376c1969a7db95f6e8d24e (patch) | |
tree | 8ce807112db390cddbe380a24401f38c74d365ab | |
parent | 28821dcf78306c9164afe01ba5e1413f3534ab8a (diff) | |
download | scintilla-mirror-fa832504c217fa68b9376c1969a7db95f6e8d24e.tar.gz |
Ensure segment discovery always makes progress even for invalid UTF-8.
-rw-r--r-- | src/Document.cxx | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index fd71a1363..fae97856a 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -721,7 +721,12 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) { lastEncodingAllowedBreak = j; if (dbcsCodePage == SC_CP_UTF8) { - j += (ch < 0x80) ? 1 : BytesFromLead(ch); + if (ch < 0x80) { + j++; + } else { + int bytes = BytesFromLead(ch); + j += bytes ? bytes : 1; + } } else if (dbcsCodePage) { j += IsDBCSLeadByte(ch) ? 2 : 1; } else { |