# HG changeset patch # User Chris Cannam # Date 1409740959 -3600 # Node ID 312b92ffb04e258b3329a1d3c5d7eacc10534141 # Parent f84f1828420b255452bb0de000be8aa915130450 Fix potential divide by zero diff -r f84f1828420b -r 312b92ffb04e layer/SliceLayer.cpp --- 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) {