martinez
martinez copied to clipboard
Handling of unclosed coordinates.
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!
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!