Explorar o código

Fix runtime exception

(cherry picked from commit c94a957803e0535966f04ade3455ff742470759d)
Felix Paul Kühne %!s(int64=9) %!d(string=hai) anos
pai
achega
7fc99223de
Modificáronse 1 ficheiros con 10 adicións e 5 borrados
  1. 10 5
      Sources/VLCLibraryViewController.m

+ 10 - 5
Sources/VLCLibraryViewController.m

@@ -719,15 +719,20 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
     NSManagedObject *selectedObject;
 
-    if (tableView == self.searchDisplayController.searchResultsTableView)
-        selectedObject = _searchData[indexPath.row];
-    else
-        selectedObject = _foundMedia[indexPath.row];
+    NSUInteger row = indexPath.row;
+    if (tableView == self.searchDisplayController.searchResultsTableView) {
+        if (row < _searchData.count)
+            selectedObject = _searchData[row];
+    } else {
+        if (row < _foundMedia.count)
+            selectedObject = _foundMedia[row];
+    }
 
     if (_searchDisplayController.active)
         [_searchDisplayController setActive:NO animated:NO];
 
-    [self openMediaObject:selectedObject];
+    if (selectedObject != nil)
+        [self openMediaObject:selectedObject];
 }
 
 #pragma mark - Gesture Action