Skip to content

ScatterSource: GetNearest() Crashes when MaxRenderIndex is set to certain values #3616

@Matthew-Chidlow

Description

@Matthew-Chidlow

Issue:
Calling GetNearest() on any of the ScatterSources types will always crash for any input data except if
you manually set MaxRenderIndex to something at least 2 less than the number of actual points (this has other side effects so is only a temp work around which can be mitigated by adding dummy points).

I believe the issue is that the upper bounds on these for loops need to be exclusive not inclusive:

for (int i2 = 0; i2 <= RenderIndexCount; i2++)

for (int i2 = 0; i2 <= RenderIndexCount; i2++)

for (int i2 = 0; i2 <= RenderIndexCount; i2++)

for (int i2 = 0; i2 <= RenderIndexCount; i2++)

ScottPlot Version: 5.0.24

Code Sample:

 new ScatterSourceDoubleArray(Array.Empty<double>(), Array.Empty<double>()).GetNearest(default, default);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions