From fd9de7fbf3628a81a2681775f19428ebc1e8cd1b Mon Sep 17 00:00:00 2001 From: Ostap Taran Date: Tue, 4 Aug 2015 13:37:36 +0300 Subject: [PATCH] Fixed issue with Out-Of-Range exception --- Classes/TOMSMorphingLabel.m | 4 ++++ 1 file changed, 4 insertions(+) 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];