From ec2fd5b38f3a574d3c4d0a4039e03fa19a2848bc Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 30 Jun 2024 06:45:48 +0200 Subject: [PATCH] prevent crash in hw bsp --- src/hardware/hw_bsp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 91759c819..a5f76df06 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -667,9 +667,15 @@ static boolean PointInSeg(polyvertex_t *a,polyvertex_t *v1,polyvertex_t *v2) // v1 = origine ax= v2->x-v1->x; ay= v2->y-v1->y; - norm = (float)hypot(ax, ay); - ax /= norm; - ay /= norm; + norm = hypotf(ax, ay); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfloat-equal" + if (norm != 0) // yes, this can be exactly 0 +#pragma GCC diagnostic pop + { + ax /= norm; + ay /= norm; + } bx = a->x-v1->x; by = a->y-v1->y; //d = a.b