From f0e0b515ad0a88422bed694c1111832a589cb259 Mon Sep 17 00:00:00 2001 From: Russ Date: Fri, 14 Jun 2019 00:49:32 -0700 Subject: [PATCH] avoid divide by zero --- src/widgets/barchart.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/barchart.rs b/src/widgets/barchart.rs index 0600973..be833cc 100644 --- a/src/widgets/barchart.rs +++ b/src/widgets/barchart.rs @@ -133,7 +133,7 @@ impl<'a> Widget for BarChart<'a> { .data .iter() .take(max_index) - .map(|&(l, v)| (l, v * u64::from(chart_area.height) * 8 / max)) + .map(|&(l, v)| (l, v * u64::from(chart_area.height) * 8 / std::cmp::max(max, 1))) .collect::>(); for j in (0..chart_area.height - 1).rev() { for (i, d) in data.iter_mut().enumerate() {