martinez icon indicating copy to clipboard operation
martinez copied to clipboard

Handling of unclosed coordinates.

Open erikh2000 opened this issue 7 years ago • 1 comments

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!

erikh2000 avatar Jan 26 '18 23:01 erikh2000

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!

rowanwins avatar Jan 27 '18 02:01 rowanwins