From 2e9bd5dc34bdc53dc01d7109988f03b37175302d Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Mon, 8 Sep 2014 01:00:26 +0200 Subject: [PATCH] Avoid a possible division-by-zero, and cast to a double to avoid premature precision loss Based on TortoiseSVN revision #25839. Signed-off-by: Sven Strickroth --- src/Utils/MiscUI/MyGraph.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Utils/MiscUI/MyGraph.cpp b/src/Utils/MiscUI/MyGraph.cpp index c3e7ba29e..7a577220d 100644 --- a/src/Utils/MiscUI/MyGraph.cpp +++ b/src/Utils/MiscUI/MyGraph.cpp @@ -1131,7 +1131,8 @@ void MyGraph::DrawSeriesBar(CDC& dc) const double maxSeriesPlotSize(0.0); if(!m_bStackedGraph){ - barWidth = seriesSpace / GetMaxNonZeroSeriesSize(); + int seriessize = GetMaxNonZeroSeriesSize(); + barWidth = seriessize ? seriesSpace / seriessize : 0; if (1 < GetNonZeroSeriesCount()) { barWidth *= INTERSERIES_PERCENT_USED; } @@ -1273,7 +1274,7 @@ void MyGraph::DrawSeriesLine(CDC& dc) const int nMaxDataValue(GetMaxDataValue()); nMaxDataValue = max(nMaxDataValue, 1); double dLineHeight(pSeries->GetData(nGroup) * m_nYAxisHeight / - nMaxDataValue); + double(nMaxDataValue)); ptLoc.y = (int) ((double) m_ptOrigin.y - dLineHeight); -- 2.11.4.GIT