Fixed an out of range exception if we try to read a invalid color format in srt.
This commit is contained in:
1 parent
944b9b375b
commit
133942e78d
1 file changed
+5
-2
@@ -137,16 +137,18 @@ int compare_color(rgba_color c1, rgba_color c2) {
|
|||||||
contentInternalRange.length -=1;
|
contentInternalRange.length -=1;
|
||||||
content = [_text substringWithRange:contentInternalRange];
|
content = [_text substringWithRange:contentInternalRange];
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
tagType = kTagOpen;
|
tagType = kTagOpen;
|
||||||
|
}
|
||||||
|
|
||||||
if ([content hasPrefix:@"font"]) {
|
if ([content hasPrefix:@"font"]) {
|
||||||
style = [[MP42Style alloc] initWithStyle:kStyleColor type:tagType location:openRange.location color: _defaultColor];
|
style = [[MP42Style alloc] initWithStyle:kStyleColor type:tagType location:openRange.location color: _defaultColor];
|
||||||
if (tagType == kTagOpen) {
|
if (tagType == kTagOpen) {
|
||||||
NSRange colorRange = [content rangeOfString:@"color=\"#"];
|
NSRange colorRange = [content rangeOfString:@"color=\"#"];
|
||||||
if (colorRange.location != NSNotFound && colorRange.location < [content length]) {
|
if (colorRange.location != NSNotFound && colorRange.location < content.length) {
|
||||||
colorRange.location += 8;
|
colorRange.location += 8;
|
||||||
colorRange.length = 6;
|
colorRange.length = 6;
|
||||||
|
if ((colorRange.location + colorRange.location) < content.length) {
|
||||||
NSString *color = [content substringWithRange:colorRange];
|
NSString *color = [content substringWithRange:colorRange];
|
||||||
const char *r = [[color substringWithRange:NSMakeRange(0, 2)] UTF8String];
|
const char *r = [[color substringWithRange:NSMakeRange(0, 2)] UTF8String];
|
||||||
const char *g = [[color substringWithRange:NSMakeRange(2, 2)] UTF8String];
|
const char *g = [[color substringWithRange:NSMakeRange(2, 2)] UTF8String];
|
||||||
@@ -159,6 +161,7 @@ int compare_color(rgba_color c1, rgba_color c2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if ([content hasPrefix:@"b"]) {
|
else if ([content hasPrefix:@"b"]) {
|
||||||
style = [[MP42Style alloc] initWithStyle:kStyleBold type:tagType location:openRange.location color:_defaultColor];
|
style = [[MP42Style alloc] initWithStyle:kStyleBold type:tagType location:openRange.location color:_defaultColor];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user