mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Fix crash truncating a string of a node with a zero size
The crash happens in the placeholderImage of ASTextNode. The node is not visible in the time it try to get the `placeholderImage` and so the `visibleRange` has count 0 and a crash happens while accessing the first object of an empty array.
This commit is contained in:
@@ -59,7 +59,6 @@
|
||||
NSAttributedString *truncationAttributedString = self.attributes.truncationAttributedString;
|
||||
|
||||
// get the index of the last character, so we can handle text in the truncation token
|
||||
NSRange visibleRange = self.truncater.visibleRanges[0];
|
||||
__block NSRange truncationTokenRange = { NSNotFound, 0 };
|
||||
|
||||
[truncationAttributedString enumerateAttribute:ASTextKitTruncationAttributeName inRange:NSMakeRange(0, truncationAttributedString.length)
|
||||
@@ -75,6 +74,7 @@
|
||||
truncationTokenRange = { 0, truncationAttributedString.length };
|
||||
}
|
||||
|
||||
NSRange visibleRange = self.truncater.firstVisibleRange;
|
||||
truncationTokenRange.location += NSMaxRange(visibleRange);
|
||||
|
||||
__block CGFloat minDistance = CGFLOAT_MAX;
|
||||
|
||||
Reference in New Issue
Block a user