From 6cdf72427c7d9da2621bb4cf8375c13060ec4310 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 19 Dec 2021 18:34:04 +0400 Subject: [PATCH] Check if broken line range is out of string length --- submodules/Display/Source/TextNode.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/submodules/Display/Source/TextNode.swift b/submodules/Display/Source/TextNode.swift index 1fb4070ea1..03be16238d 100644 --- a/submodules/Display/Source/TextNode.swift +++ b/submodules/Display/Source/TextNode.swift @@ -1034,6 +1034,9 @@ public class TextNode: ASDisplayNode { coreTextLine = CTLineCreateTruncatedLine(originalLine, Double(lineConstrainedSize.width), truncationType, truncationToken) ?? truncationToken brokenLineRange.length = CTLineGetGlyphCount(coreTextLine) - 1 + if brokenLineRange.location + brokenLineRange.length > attributedString.length { + brokenLineRange.length = attributedString.length - brokenLineRange.location + } truncated = true }