diff options
| author | Cody Robibero <cody@robibe.ro> | 2026-07-25 08:38:43 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-25 08:38:43 -0400 |
| commit | ebb66f6ca3051ca04f150d60a3e8f52a5b105261 (patch) | |
| tree | 3b6f379ab6a058aa1df37f768ef7d3e2c7c05c97 /Emby.Server.Implementations/Library/LibraryManager.cs | |
| parent | b85c9186ef1f4f83308f65f9066d160ddb5ab689 (diff) | |
| parent | 8b70582561754d22fababede84316beead46d3a9 (diff) | |
Merge pull request #17395 from paoloantinori/fix/userdata-null-user-nre-master
Avoid NRE when sorting by user-dependent keys without a user
Diffstat (limited to 'Emby.Server.Implementations/Library/LibraryManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/LibraryManager.cs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index f684f4dca3..52569ed66a 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -2315,9 +2315,13 @@ namespace Emby.Server.Implementations.Library { var comparer = Comparers.FirstOrDefault(c => name == c.Type); - // If it requires a user, create a new one, and assign the user if (comparer is IUserBaseItemComparer) { + if (user is null) + { + throw new ArgumentException($"Sort key '{name}' requires a user, but none was provided."); + } + var userComparer = (IUserBaseItemComparer)Activator.CreateInstance(comparer.GetType())!; // only null for Nullable<T> instances userComparer.User = user; |
