From 766710c1d5a8c02ed625b7dc36c6c948eb020fd0 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 12 Sep 2025 01:47:49 -0700 Subject: charts: guard against potential negative values Since vcr_draw_bar() will assert on a negative height be more defensive here --- src/charts.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/charts.c b/src/charts.c index c4e51e3..30eca06 100644 --- a/src/charts.c +++ b/src/charts.c @@ -416,10 +416,14 @@ static void draw_bars(vwm_charts_t *charts, vwm_chart_t *chart, int row, float m a_t = a_fraction * inv_a_total * mult; if (a_t > 1.f) a_t = 1.f; + else if (a_t < 0.f) + a_t = 0.f; b_t = b_fraction * inv_b_total * mult; if (b_t > 1.f) b_t = 1.f; + else if (b_t < 0.f) + b_t = 0.f; /* ensure at least 1 pixel when the scaled result is a fraction less than 1, * I want to at least see 1 pixel blips for the slightest cpu utilization */ -- cgit v1.2.3