Fix potential mod nullref in APIUserScoreAggregate's CreateScoreInfo implementation

This commit is contained in:
Dean Herbert 2022-01-13 00:28:16 +09:00
parent b2d09b7b10
commit 4c79145c11
2 changed files with 5 additions and 4 deletions

View File

@ -1,7 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring; using osu.Game.Scoring;
namespace osu.Game.Online.API.Requests.Responses namespace osu.Game.Online.API.Requests.Responses
@ -42,7 +44,8 @@ namespace osu.Game.Online.API.Requests.Responses
PP = PP, PP = PP,
TotalScore = TotalScore, TotalScore = TotalScore,
User = User, User = User,
Position = Position Position = Position,
Mods = Array.Empty<Mod>()
}; };
} }
} }

View File

@ -186,14 +186,12 @@ namespace osu.Game.Scoring
{ {
get get
{ {
var rulesetInstance = Ruleset.CreateInstance();
Mod[] scoreMods = Array.Empty<Mod>(); Mod[] scoreMods = Array.Empty<Mod>();
if (mods != null) if (mods != null)
scoreMods = mods; scoreMods = mods;
else if (localAPIMods != null) else if (localAPIMods != null)
scoreMods = APIMods.Select(m => m.ToMod(rulesetInstance)).ToArray(); scoreMods = APIMods.Select(m => m.ToMod(Ruleset.CreateInstance())).ToArray();
return scoreMods; return scoreMods;
} }