summaryrefslogtreecommitdiff
path: root/src/mbgl/style
diff options
context:
space:
mode:
authorzmiao <miao.zhao@mapbox.com>2020-04-07 16:30:30 +0300
committerGitHub <noreply@github.com>2020-04-07 16:30:30 +0300
commitbf4c7340f32c1e673e6a37b91fc65305757f52d1 (patch)
treec7871ff8901617b09d8a8d45b57334c2198b9b99 /src/mbgl/style
parent8986b558eb92e431c773b6033d8ae271eb71de00 (diff)
downloadqtlocation-mapboxgl-bf4c7340f32c1e673e6a37b91fc65305757f52d1.tar.gz
[build] Fix undefined behavour sanitizer (#16375)
* [build] Fix integer overflow runtime error for core part Temporarily remove circle ci UBSAN build precondition * [build] Enable all of the ubsans [build] Check runtime error [build] Update UBSAN_OPTION * [build] Add UBSAN blacklist [build] Ignore system libraries [build] Ignore vendor library * [build] Fix implicit conversion runtime error in core * [build] Fix division by zero runtime error * [build] Add unfixed error to ubsan blacklist * [build] Make UBSAN halt on error Revert "Temporary remove build precondition" * [build] Fix division by zero error * [build] Make UBSAN officially work without FIXME prefix * [build] Fix implicit conversion from int64_t to uint64_t * [build] Rename style test json file name * Address review findings
Diffstat (limited to 'src/mbgl/style')
-rw-r--r--src/mbgl/style/expression/compound_expression.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp
index 2477fe7917..bae0258aa0 100644
--- a/src/mbgl/style/expression/compound_expression.cpp
+++ b/src/mbgl/style/expression/compound_expression.cpp
@@ -15,6 +15,7 @@
#include <mapbox/eternal.hpp>
#include <cmath>
+#include <limits>
namespace mbgl {
namespace style {
@@ -498,7 +499,15 @@ const auto& multiplyCompoundExpression() {
}
const auto& divideCompoundExpression() {
- static auto signature = detail::makeSignature("/", [](double a, double b) -> Result<double> { return a / b; });
+ static auto signature = detail::makeSignature("/", [](double a, double b) -> Result<double> {
+ if (b == 0) {
+ if (a == 0) return std::numeric_limits<double>::quiet_NaN();
+ double inf = std::numeric_limits<double>::infinity();
+ if (a > 0) return inf;
+ if (a < 0) return -inf;
+ }
+ return a / b;
+ });
return signature;
}