From b3e0da6fe997209f9e42da1f4c28378078069ba6 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 3 Jul 2022 14:30:29 -0700 Subject: [PATCH] [M3U Playlist] Reformulate safety checks Apparently someone managed to crash this with their playlists. No idea how. Added more safety checks. Signed-off-by: Christopher Snowhill --- Plugins/M3u/M3uContainer.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Plugins/M3u/M3uContainer.m b/Plugins/M3u/M3uContainer.m index 017232ed2..50eb71f06 100644 --- a/Plugins/M3u/M3uContainer.m +++ b/Plugins/M3u/M3uContainer.m @@ -122,14 +122,19 @@ for(NSString *entry in [contents componentsSeparatedByString:@"\n"]) { NSString *_entry = [entry stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + if(_entry == nil || [_entry length] < 1) continue; + if([_entry hasPrefix:@"#EXT-X-MEDIA-SEQUENCE"]) // Let FFmpeg handle HLS return @[]; - if([_entry hasPrefix:@"#"] || [_entry isEqualToString:@""]) // Ignore extra info + if([_entry hasPrefix:@"#"]) // Ignore extra info continue; // Need to add basePath, and convert to URL - [entries addObject:[self urlForPath:_entry relativeTo:[url path]]]; + NSURL *fileUrl = [self urlForPath:_entry relativeTo:[url path]]; + + if(fileUrl) + [entries addObject:fileUrl]; } return entries;