From 831501ea41de39c63d3983f8140e425f4468ee5a Mon Sep 17 00:00:00 2001 From: PoliEcho Date: Tue, 11 Aug 2026 12:06:03 +0200 Subject: [PATCH] fix possible wraparound --- src/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f343902..0b2f598 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #ifndef CONFIG_AUTOSCALE constexpr @@ -184,8 +185,8 @@ int main() { const float vector_lenght = (speed_pph / 60) * CONFIG_TIME_BASED_VECTOR_LENGHT; draw::line(x_center, y_center, - x_center + (vector_lenght * std::cos(track_rad)), - y_center + (vector_lenght * std::sin(track_rad)), color); + std::clamp(x_center + (vector_lenght * std::cos(track_rad)),0.0f, static_cast(UINT16_MAX)), + std::clamp(y_center + (vector_lenght * std::sin(track_rad)),0.0f,static_cast(UINT16_MAX)), color); #endif draw::rhombus(x_center, y_center, 8 /*TODO: remove magic*/, color);