Mercurial > hg > svgui
diff layer/SliceLayer.cpp @ 847:312b92ffb04e
Fix potential divide by zero
author | Chris Cannam |
---|---|
date | Wed, 03 Sep 2014 11:42:39 +0100 |
parents | 1d526ba11a24 |
children | 12ab113ca2b1 |
line wrap: on
line diff
--- a/layer/SliceLayer.cpp Wed Sep 03 11:41:58 2014 +0100 +++ b/layer/SliceLayer.cpp Wed Sep 03 11:42:39 2014 +0100 @@ -396,7 +396,9 @@ float max = 0.f; for (int bin = 0; bin < mh; ++bin) { - if (m_samplingMode == SampleMean) m_values[bin] /= divisor; + if (m_samplingMode == SampleMean && divisor > 0) { + m_values[bin] /= divisor; + } if (m_values[bin] > max) max = m_values[bin]; } if (max != 0.f && m_normalize) {