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:
@@ -140,6 +140,15 @@ static BOOL CGSizeEqualToSizeWithIn(CGSize size1, CGSize size2, CGFloat delta)
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testMeasureWithZeroSizeAndPlaceholder
|
||||
{
|
||||
_textNode.placeholderEnabled = YES;
|
||||
|
||||
XCTAssertNoThrow([_textNode measure:CGSizeZero], @"Measure with zero size and placeholder enabled should not throw an exception");
|
||||
XCTAssertNoThrow([_textNode measure:CGSizeMake(0, 100)], @"Measure with zero width and placeholder enabled should not throw an exception");
|
||||
XCTAssertNoThrow([_textNode measure:CGSizeMake(100, 0)], @"Measure with zero height and placeholder enabled should not throw an exception");
|
||||
}
|
||||
|
||||
- (void)testAccessibility
|
||||
{
|
||||
_textNode.attributedText = _attributedText;
|
||||
|
||||
Reference in New Issue
Block a user