diff --git a/Classes/TOMSMorphingLabel.m b/Classes/TOMSMorphingLabel.m index ed77c05..b0c3439 100644 --- a/Classes/TOMSMorphingLabel.m +++ b/Classes/TOMSMorphingLabel.m @@ -369,6 +369,10 @@ - (void)applyAttributionStage:(NSInteger)stage toString:(NSString *)aString NSInteger attributionIndex = (NSInteger)(offset - entryPoint); attributionIndex = MIN(self.numberOfAttributionStages - 1, MAX(0, attributionIndex)); + if (range.location + range.length > aString.length) { + continue; + } + NSMutableDictionary *attributionStage = self.attributionStages[attributionIndex]; CGFloat kernFactor = [attributionStage[kTOMSKernFactorAttributeName] floatValue]; NSString *character = [aString substringWithRange:range];