Commit 7d4bfe42 authored by Felix Paul Kühne's avatar Felix Paul Kühne

VLCNetworkServerBrowserViewController: add sanity checks to prevent out-of-bounds exceptions

This can occur if the list of items changes while the user navigates the list and decides for an item to play
parent 05a1af07
...@@ -188,14 +188,19 @@ ...@@ -188,14 +188,19 @@
id<VLCNetworkServerBrowserItem> item; id<VLCNetworkServerBrowserItem> item;
NSInteger row = indexPath.row; NSInteger row = indexPath.row;
BOOL singlePlayback = ![[NSUserDefaults standardUserDefaults] boolForKey:kVLCAutomaticallyPlayNextItem]; BOOL singlePlayback = ![[NSUserDefaults standardUserDefaults] boolForKey:kVLCAutomaticallyPlayNextItem];
if (self.searchController.isActive) { if (self.searchController.isActive && row < _searchArray.count) {
item = _searchArray[row]; item = _searchArray[row];
singlePlayback = YES; singlePlayback = YES;
} else { } else {
item = self.serverBrowser.items[row]; NSArray *items = self.serverBrowser.items;
if (row < items.count) {
item = items[row];
}
} }
[self didSelectItem:item index:row singlePlayback:singlePlayback]; if (item) {
[self didSelectItem:item index:row singlePlayback:singlePlayback];
}
[tableView deselectRowAtIndexPath:indexPath animated:NO]; [tableView deselectRowAtIndexPath:indexPath animated:NO];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment