diff --git a/PKHeX.Core/PKM/Shared/PokeList1.cs b/PKHeX.Core/PKM/Shared/PokeList1.cs index 5b85675b0..3ba95c7ad 100644 --- a/PKHeX.Core/PKM/Shared/PokeList1.cs +++ b/PKHeX.Core/PKM/Shared/PokeList1.cs @@ -173,7 +173,8 @@ public static void Unpack(ReadOnlySpan input, Span output, int strin var ofsStr1 = ofsBody + (capacity * lengthBody); var ofsStr2 = ofsStr1 + (capacity * stringLength); - for (int i = 0; i < capacity; i++) + var count = Math.Min(capacity, input[0]); + for (int i = 0; i < count; i++) { var species = input[1 + i]; var body = input.Slice(ofsBody, lengthBody); diff --git a/PKHeX.Core/PKM/Shared/PokeList2.cs b/PKHeX.Core/PKM/Shared/PokeList2.cs index d886d0d65..44c262bd9 100644 --- a/PKHeX.Core/PKM/Shared/PokeList2.cs +++ b/PKHeX.Core/PKM/Shared/PokeList2.cs @@ -177,7 +177,8 @@ public static void Unpack(ReadOnlySpan input, Span output, int strin var ofsStr1 = ofsBody + (capacity * lengthBody); var ofsStr2 = ofsStr1 + (capacity * stringLength); - for (int i = 0; i < capacity; i++) + var count = Math.Min(capacity, input[0]); + for (int i = 0; i < count; i++) { var species = input[1 + i]; var body = input.Slice(ofsBody, lengthBody);