Bounds check empty permutations

If the length is 0 or malformed input, we return empty.
This commit is contained in:
Kurt 2021-01-02 19:23:39 -08:00
parent 1f3d3112d3
commit 7629d3f887

View file

@ -125,7 +125,7 @@ namespace PKHeX.Core
private static IEnumerable<IEnumerable<T>> GetPermutations<T>(ICollection<T> list, int length)
{
// https://stackoverflow.com/a/10630026
if (length == 1)
if ((uint)length <= 1)
return list.Select(t => new[] { t });
return GetPermutations(list, length - 1)