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 of unclosed coordinates. #57

Open
erikh2000 opened this issue Jan 26, 2018 · 1 comment
Open

Handling of unclosed coordinates. #57

erikh2000 opened this issue Jan 26, 2018 · 1 comment

Comments

@erikh2000
Copy link

erikh2000 commented Jan 26, 2018

Hello!

If I call diff() and one of the passed polygons is missing or has an incorrect ending coordinate, the function will get caught in some kind of loop and eventually Javascript heap memory will be exhausted.

const a = [[[0,0],[10,0],[10,10],[0,10],[0,0]]];
const b = [[[10,0],[10,10],[20,10],[20,0],[0,0]]]; // Bad ending coordinate.
difference(a,b);

Of course, this is my error in calling, since the b coordinates are invalid. But I suggest that this is a good case to catch with a simple check so that the function exits quickly without tying up the processor.

I'm quite happy with the library so far. Thanks so much!

@rowanwins
Copy link
Collaborator

Good pickup thanks @erikh2000 . To be honest I'm kinda surprised that this happens, but as you say it's an easy fix so that's good!

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

No branches or pull requests

3 participants