From 8c03ea3d68dcd4b353f92372cafc67698f6ed528 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 12 May 2014 10:14:10 +0100 Subject: [PATCH] mapnik::value - return 'infinity' if rhs == 0 to avoid division by zero --- include/mapnik/value.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index 18979d8df..631f2baa3 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -495,6 +495,7 @@ struct div: public boost::static_visitor template value_type operator() (T lhs, T rhs) const { + if (rhs == 0) return std::numeric_limits::infinity(); return lhs / rhs; } @@ -513,11 +514,13 @@ struct div: public boost::static_visitor value_type operator() (value_double lhs, value_integer rhs) const { + if (rhs == 0) return std::numeric_limits::infinity(); return lhs / rhs; } value_type operator() (value_integer lhs, value_double rhs) const { + if (rhs == 0) return std::numeric_limits::infinity(); return lhs / rhs; } };