From 4c79145c11fc54f28ec9ef23f12520791f44df43 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jan 2022 00:28:16 +0900 Subject: [PATCH] Fix potential mod nullref in `APIUserScoreAggregate`'s `CreateScoreInfo` implementation --- .../Online/API/Requests/Responses/APIUserScoreAggregate.cs | 5 ++++- osu.Game/Scoring/ScoreInfo.cs | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIUserScoreAggregate.cs b/osu.Game/Online/API/Requests/Responses/APIUserScoreAggregate.cs index 9a7f0832a6..a298a8625a 100644 --- a/osu.Game/Online/API/Requests/Responses/APIUserScoreAggregate.cs +++ b/osu.Game/Online/API/Requests/Responses/APIUserScoreAggregate.cs @@ -1,7 +1,9 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using Newtonsoft.Json; +using osu.Game.Rulesets.Mods; using osu.Game.Scoring; namespace osu.Game.Online.API.Requests.Responses @@ -42,7 +44,8 @@ namespace osu.Game.Online.API.Requests.Responses PP = PP, TotalScore = TotalScore, User = User, - Position = Position + Position = Position, + Mods = Array.Empty() }; } } diff --git a/osu.Game/Scoring/ScoreInfo.cs b/osu.Game/Scoring/ScoreInfo.cs index ffec54aca7..45e5b8f1a7 100644 --- a/osu.Game/Scoring/ScoreInfo.cs +++ b/osu.Game/Scoring/ScoreInfo.cs @@ -186,14 +186,12 @@ namespace osu.Game.Scoring { get { - var rulesetInstance = Ruleset.CreateInstance(); - Mod[] scoreMods = Array.Empty(); if (mods != null) scoreMods = mods; else if (localAPIMods != null) - scoreMods = APIMods.Select(m => m.ToMod(rulesetInstance)).ToArray(); + scoreMods = APIMods.Select(m => m.ToMod(Ruleset.CreateInstance())).ToArray(); return scoreMods; }