avoid potential zero division resulting in nan in agg::gamma_linear - closes #761

This commit is contained in:
Dane Springmeyer 2013-03-14 17:48:59 -07:00
parent 94c5645e8b
commit 7e974b9064

View file

@ -85,7 +85,11 @@ namespace agg
{
if(x < m_start) return 0.0;
if(x > m_end) return 1.0;
return (x - m_start) / (m_end - m_start);
double delta = m_end - m_start;
// avoid nan from potential zero division
// https://github.com/mapnik/mapnik/issues/761
if (delta <= 0.0) return 0.0;
return (x - m_start) / delta;
}
private: