From 348cc263d06cb8f47b5cd0528a42303bedf12846 Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Sat, 26 Aug 2023 15:55:02 +0800 Subject: [PATCH] Explicitly ignore NaN values in BarMeterMode_draw() Do not throw FP exceptions if any value in a Meter object is a NaN. Signed-off-by: Kang-Che Sung --- Meter.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Meter.c b/Meter.c index 27e4cd0c0..5991a9c9f 100644 --- a/Meter.c +++ b/Meter.c @@ -225,8 +225,9 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) { int offset = 0; for (uint8_t i = 0; i < this->curItems; i++) { double value = this->values[i]; - value = CLAMP(value, 0.0, this->total); - if (value > 0) { + if (isPositive(value)) { + assert(this->total > 0.0); + value = MINIMUM(value, this->total); blockSizes[i] = ceil((value / this->total) * w); } else { blockSizes[i] = 0;