From 15dbbe9abd99f71a6da83079f92d383802e82aab Mon Sep 17 00:00:00 2001 From: Gilbert Corrales Date: Mon, 4 Nov 2013 00:34:10 +0200 Subject: [PATCH] adds check for out of bouds indexes in sigs this happens when the videos comes with ads, happened when running the code in US --- LBYouTubeView/LBYouTubeExtractor.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LBYouTubeView/LBYouTubeExtractor.m b/LBYouTubeView/LBYouTubeExtractor.m index 1906258..1048b6d 100644 --- a/LBYouTubeView/LBYouTubeExtractor.m +++ b/LBYouTubeView/LBYouTubeExtractor.m @@ -126,7 +126,8 @@ -(NSURL*)extractYouTubeURLFromFile:(NSString *)html error:(NSError *__autoreleas // Check the signature: if ([sigs count] > 0) { - sigCheckingResult = [sigs objectAtIndex:index]; + unsigned int idx = MIN(index,sigs.count-1); + sigCheckingResult = [sigs objectAtIndex:idx]; NSString* encrSyg = [string substringWithRange:sigCheckingResult.range]; sig_regex = [[NSRegularExpression alloc] initWithPattern:@"(?<=sig\\\\\": \\\\\")[^\"]*?(?=\\\\\")" options:NSRegularExpressionCaseInsensitive error:nil];