From 7f12f929e55de91d1cd467edc63f0e146ea6d618 Mon Sep 17 00:00:00 2001 From: bakedpotatolord Date: Wed, 18 Jun 2025 20:15:34 -0600 Subject: [PATCH] add typecheck to avoid dangerous code that can cause infinite looping --- src/geo/base.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/geo/base.js b/src/geo/base.js index 1e64af86..e851e803 100644 --- a/src/geo/base.js +++ b/src/geo/base.js @@ -405,6 +405,10 @@ function center2pr(p1, p2, r, clockwise) { // find angle difference between 0 and 2pi from n1 to n2 (signed depending on clock direction) function thetaDiff(n1, n2, clockwise) { let diff = n2 - n1; + if(typeof n1 != 'number' || typeof n2 != 'number') { + throw ("n1 and n2 must be numbers"); + // this check is here because this causes an infinite loop when other value are provided + } while (diff < -Math.PI) diff += Math.PI * 2; while (diff > Math.PI) diff -= Math.PI * 2; if (clockwise && diff > 0) diff -= Math.PI * 2;