Pārlūkot izejas kodu

VLCSharedLibraryParser: Fix potential crash on unknown selector

It was assumed that parsedContents was always an array of
NSDictionnary.

This makes sure that the object is a NSDictionnary in order to avoid a
potential crash.

Indeed in some rare cases, it seemed that the first object can be a
NSString which leads to a crash with unknown selector.
Soomin Lee 5 gadi atpakaļ
vecāks
revīzija
dfb937cb20

+ 6 - 4
SharedSources/ServerBrowsing/HTTP/VLCSharedLibraryParser.m

@@ -35,10 +35,12 @@ NSString *const VLCSharedLibraryParserDeterminedNetserviceAsVLCInstance = @"VLCS
     NSArray *parsedContents = [self downloadAndProcessDataFromServer:hostnamePort];
 
     if (parsedContents.count > 0) {
-        if ([[parsedContents.firstObject objectForKey:@"identifier"] isEqualToString:@"org.videolan.vlc-ios"]) {
-            [[NSNotificationCenter defaultCenter] postNotificationName:VLCSharedLibraryParserDeterminedNetserviceAsVLCInstance
-                                                                object:self
-                                                              userInfo:@{@"aNetService" : aNetService}];
+        if ([parsedContents.firstObject isKindOfClass:[NSDictionary class]]) {
+            if ([[parsedContents.firstObject objectForKey:@"identifier"] isEqualToString:@"org.videolan.vlc-ios"]) {
+                [[NSNotificationCenter defaultCenter] postNotificationName:VLCSharedLibraryParserDeterminedNetserviceAsVLCInstance
+                                                                    object:self
+                                                                  userInfo:@{@"aNetService" : aNetService}];
+            }
         }
     }
 }