Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling invalid input #5

Open
arlyon opened this issue Jan 3, 2021 · 0 comments
Open

Handling invalid input #5

arlyon opened this issue Jan 3, 2021 · 0 comments

Comments

@arlyon
Copy link
Owner

arlyon commented Jan 3, 2021

There are a few input values that cause panics in rand or from bad maths. It would be nice to protect users from these.

  • width <= 0 cause range errors in rand
  • height <= 0 cause range errors in rand
  • max_samples == 0 cause divide by zero errors
  • very high widths / heights or very low min_radius causes multiplication overflow errors when creating the grid vector.

The first three are easy to handle. The last one, not so much. Integer overflow is obviously not great but what if we were to fix it? Attempted allocation for > 2^64 Vec2 is a good hundred exabytes. I am for preventing an overflow panic, but I am very against handling 'too large' grids because we don't want to impose arbitrary limits.

One option is to create a proper builder, with a build method returning something along the lines of Result<BlueNoise, BuildError>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant