diff options
author | Neil Hodgson <nyamatongwe@gmail.com> | 2018-10-04 16:23:36 +1000 |
---|---|---|
committer | Neil Hodgson <nyamatongwe@gmail.com> | 2018-10-04 16:23:36 +1000 |
commit | 8cefe7a5183c83040782b5d3611d2f0ca4037b29 (patch) | |
tree | 0ac7372a08d19743cec1729f4a8f22c3a944b15d | |
parent | a46572b4a243173c9152ccb1252ad46b5d2179ea (diff) | |
download | scintilla-mirror-8cefe7a5183c83040782b5d3611d2f0ca4037b29.tar.gz |
Fix crash when particular patterns of invalid UTF-8 led to failure to create a
CFStringRef. Performs more stringent validation on input text.
-rw-r--r-- | cocoa/PlatCocoa.mm | 5 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 4789f7528..a74c805a4 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -164,13 +164,15 @@ public: ScreenLineLayout::ScreenLineLayout(const IScreenLine *screenLine) : text(screenLine->Text()) { const UInt8 *puiBuffer = reinterpret_cast<const UInt8 *>(text.data()); + std::string_view sv = text; // Start with an empty mutable attributed string and add each character to it. CFMutableAttributedStringRef mas = CFAttributedStringCreateMutable(NULL, 0); for (size_t bp=0; bp<text.length();) { const unsigned char uch = text[bp]; - const unsigned int byteCount = UTF8BytesOfLead[uch]; + const int utf8Status = UTF8Classify(sv); + const unsigned int byteCount = utf8Status & UTF8MaskWidth; XYPOSITION repWidth = screenLine->RepresentationWidth(bp); if (uch == '\t') { // Find the size up to the tab @@ -207,6 +209,7 @@ ScreenLineLayout::ScreenLineLayout(const IScreenLine *screenLine) : text(screenL CFRangeMake(CFAttributedStringGetLength(mas), 0), as); bp += byteCount; + sv.remove_prefix(byteCount); CFRelease(as); } diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 236dbb107..5d4e6344d 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -548,6 +548,15 @@ </li> </ul> <h3> + <a href="https://www.scintilla.org/scite413.zip">Release 4.1.3</a> + </h3> + <ul> + <li> + Fixed a crash on Cocoa in bidirectional mode where some patterns of invalid UTF-8 + caused failures to create Unicode strings. + </li> + </ul> + <h3> <a href="https://www.scintilla.org/scite412.zip">Release 4.1.2</a> </h3> <ul> |