From 49a892e52ccf465ac0c56be2c71ca8812641c49a Mon Sep 17 00:00:00 2001 From: Mikael Sand Date: Thu, 9 Aug 2018 21:24:09 +0300 Subject: [PATCH] [ios] Fix substring range length calculation for unicode emoji. --- ios/Text/RNSVGTSpan.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ios/Text/RNSVGTSpan.m b/ios/Text/RNSVGTSpan.m index decd8d52..90f0d5c7 100644 --- a/ios/Text/RNSVGTSpan.m +++ b/ios/Text/RNSVGTSpan.m @@ -815,7 +815,8 @@ static double RNSVGTSpan_radToDeg = 180 / M_PI; if (width == 0) { // Render unicode emoji UILabel *label = [[UILabel alloc] init]; CFIndex startIndex = indices[g]; - NSString* currChars = [str substringWithRange:NSMakeRange(startIndex, MAX(1, endIndex - startIndex))]; + NSUInteger len = endIndex == startIndex ? n - startIndex : MAX(1, endIndex - startIndex); + NSString* currChars = [str substringWithRange:NSMakeRange(startIndex, len)]; label.text = currChars; label.opaque = NO; label.backgroundColor = UIColor.clearColor;