From 8cefe7a5183c83040782b5d3611d2f0ca4037b29 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Thu, 4 Oct 2018 16:23:36 +1000 Subject: Fix crash when particular patterns of invalid UTF-8 led to failure to create a CFStringRef. Performs more stringent validation on input text. --- cocoa/PlatCocoa.mm | 5 ++++- doc/ScintillaHistory.html | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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(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; bpRepresentationWidth(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 @@ -547,6 +547,15 @@ Icons Copyright(C) 1998 by Dean S. Jones
+

+ Release 4.1.3 +

+
    +
  • + Fixed a crash on Cocoa in bidirectional mode where some patterns of invalid UTF-8 + caused failures to create Unicode strings. +
  • +

Release 4.1.2

-- cgit v1.2.3