Resolve a System.IndexOutOfRangeException when requesting IDs that do not exist via /Users/.../Items. Previously it was possible for the 'index' values in 'positions' to refer beyond 'size'.

[ERR] Error processing request. URL "GET" "/Users/.../Items".
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at MediaBrowser.Controller.Entities.Folder.SortItemsByRequest(InternalItemsQuery query, IReadOnlyList`1 items)
   at MediaBrowser.Controller.Entities.Folder.GetItems(InternalItemsQuery query)
   at Jellyfin.Api.Controllers.ItemsController.GetItems
This commit is contained in:
Luke F 2022-07-29 20:17:30 +01:00
parent f9dffa767f
commit 3bd2cc9860

View file

@ -901,7 +901,7 @@ namespace MediaBrowser.Controller.Entities
int index = 0;
for (int i = 0; i < ids.Length; i++)
{
if (positions.TryAdd(ids[i], index))
if (items.Any(item => item.Id == ids[i]) && positions.TryAdd(ids[i], index))
{
index++;
}