Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit d70a955

Browse files
committed
Merge pull request #1111 from yury/fix-_linkAttributeValueAtPoint-crash
[ASTextNode] Fix out-of-bounds error when truncation string is longer than the original string.
2 parents 1dd6cef + f2012df commit d70a955

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

AsyncDisplayKit/ASTextNode.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ - (id)_linkAttributeValueAtPoint:(CGPoint)point
479479
ASTextKitRenderer *renderer = [self _renderer];
480480
NSRange visibleRange = renderer.visibleRanges[0];
481481
NSAttributedString *attributedString = _attributedString;
482+
NSRange clampedRange = NSIntersectionRange(visibleRange, NSMakeRange(0, attributedString.length));
482483

483484
// Check in a 9-point region around the actual touch point so we make sure
484485
// we get the best attribute for the touch.
@@ -519,7 +520,7 @@ - (id)_linkAttributeValueAtPoint:(CGPoint)point
519520

520521
for (NSString *attributeName in _linkAttributeNames) {
521522
NSRange range;
522-
id value = [attributedString attribute:attributeName atIndex:characterIndex longestEffectiveRange:&range inRange:visibleRange];
523+
id value = [attributedString attribute:attributeName atIndex:characterIndex longestEffectiveRange:&range inRange:clampedRange];
523524
NSString *name = attributeName;
524525

525526
if (value == nil || name == nil) {

0 commit comments

Comments
 (0)