Skip to content

When calling the method ToArray of the HTMLOptionsCollection class a stackoverflow exception is thrown #15

@Jeroen3000

Description

@Jeroen3000

Hi, nice library. Source code is a bit complex. Anyway, when calling the ToArray method on the HTMLOptionsCollection class it is using internally the CopyTo method, but his method is overridden and is calling ToArray again recursively. etc.. which leads to a stack overflow

I think a possible solution is to implement the CopyTo as follows:

_void ICollection.CopyTo(HTMLOptionElement[] array, int arrayIndex)
{
if (array == null)
throw new ArgumentNullException(nameof(array));
if (arrayIndex < 0)
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
if (array.Length - arrayIndex < Count)
throw new ArgumentException("Not enough elements after arrayIndex in the destination array.");

 for (int i = 0; i < Count; ++i)
     array[i + arrayIndex] = this[i];

}_

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions