Bläddra i källkod

Fix runtime exception

(cherry picked from commit e7edd11507026de007cbeffcca541b06d05f36a6)
Felix Paul Kühne 9 år sedan
förälder
incheckning
a354572f1f
1 ändrade filer med 11 tillägg och 8 borttagningar
  1. 11 8
      Sources/VLCLibraryViewController.m

+ 11 - 8
Sources/VLCLibraryViewController.m

@@ -1144,14 +1144,17 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
                         file.folderTrackNumber = @([label files].count - 1);
                         [_foundMedia removeObjectAtIndex:path.item];
                     } else {
-                        id item = _foundMedia[path.row];
-                        if (![item isKindOfClass:[MLFile class]])
-                            continue;
-
-                        MLFile *file = (MLFile *)item;
-                        file.labels = [NSSet setWithObjects:label, nil];
-                        file.folderTrackNumber = @([label files].count - 1);
-                        [_foundMedia removeObjectAtIndex:path.row];
+                        NSUInteger row = path.row;
+                        if (row < _foundMedia.count) {
+                            id item = _foundMedia[row];
+                            if (![item isKindOfClass:[MLFile class]])
+                                continue;
+
+                            MLFile *file = (MLFile *)item;
+                            file.labels = [NSSet setWithObjects:label, nil];
+                            file.folderTrackNumber = @([label files].count - 1);
+                            [_foundMedia removeObjectAtIndex:row];
+                        }
                     }
                 }
             }