summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-01-10 11:48:06 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-01-10 13:45:00 -0800
commitcedda5ef4f73fccfc795e6bc48b368e48f11ad8d (patch)
treef695cb615da4e023017d44fad8ded4259efab0fd /include
parentecbb0baf60138cea2c72ec4e75b788ca59d86e14 (diff)
downloadqtlocation-mapboxgl-cedda5ef4f73fccfc795e6bc48b368e48f11ad8d.tar.gz
[core] Handle NaN input to interpolate and step
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/style/expression/interpolate.hpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/mbgl/style/expression/interpolate.hpp b/include/mbgl/style/expression/interpolate.hpp
index 439122f91c..fd9ec25a2c 100644
--- a/include/mbgl/style/expression/interpolate.hpp
+++ b/include/mbgl/style/expression/interpolate.hpp
@@ -11,7 +11,7 @@
#include <memory>
#include <map>
-
+#include <cmath>
namespace mbgl {
namespace style {
@@ -109,9 +109,15 @@ public:
EvaluationResult evaluate(const EvaluationContext& params) const override {
const EvaluationResult evaluatedInput = input->evaluate(params);
- if (!evaluatedInput) { return evaluatedInput.error(); }
+ if (!evaluatedInput) {
+ return evaluatedInput.error();
+ }
+
float x = *fromExpressionValue<float>(*evaluatedInput);
-
+ if (std::isnan(x)) {
+ return EvaluationError { "Input is not a number." };
+ }
+
if (stops.empty()) {
return EvaluationError { "No stops in exponential curve." };
}