Add array sanitization if error was thrown

This commit is contained in:
Kurt 2021-06-07 19:59:08 -07:00
parent a07549f013
commit f7423daf7a

View file

@ -120,6 +120,16 @@ namespace PKHeX.Core
{
System.Diagnostics.Debug.WriteLine(e.Message);
Valid = false;
// Moves and Relearn arrays can potentially be empty on error.
// ReSharper disable once ConstantNullCoalescingCondition
for (int i = 0; i < Info.Moves.Length; i++)
Info.Moves[i] ??= new CheckMoveResult(MoveSource.None, pkm.Format, Severity.Indeterminate, L_AError, CheckIdentifier.CurrentMove);
// ReSharper disable once ConstantNullCoalescingCondition
for (int i = 0; i < Info.Relearn.Length; i++)
Info.Relearn[i] ??= new CheckResult(Severity.Indeterminate, L_AError, CheckIdentifier.CurrentMove);
AddLine(Severity.Invalid, L_AError, CheckIdentifier.Misc);
}
#endif