changeset 847:312b92ffb04e

Fix potential divide by zero
author Chris Cannam
date Wed, 03 Sep 2014 11:42:39 +0100
parents f84f1828420b
children 856dbe997dcd
files layer/SliceLayer.cpp
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
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) {