diff options
author | zmiao <miao.zhao@mapbox.com> | 2020-04-07 16:30:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-07 16:30:30 +0300 |
commit | bf4c7340f32c1e673e6a37b91fc65305757f52d1 (patch) | |
tree | c7871ff8901617b09d8a8d45b57334c2198b9b99 /src/mbgl/util | |
parent | 8986b558eb92e431c773b6033d8ae271eb71de00 (diff) | |
download | qtlocation-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/util')
-rw-r--r-- | src/mbgl/util/premultiply.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/util/tiny_sdf.cpp | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/mbgl/util/premultiply.cpp b/src/mbgl/util/premultiply.cpp index d9fb2480de..02c045fbb4 100644 --- a/src/mbgl/util/premultiply.cpp +++ b/src/mbgl/util/premultiply.cpp @@ -40,9 +40,9 @@ UnassociatedImage unpremultiply(PremultipliedImage&& src) { uint8_t& b = data[i + 2]; uint8_t& a = data[i + 3]; if (a) { - r = (255 * r + (a / 2)) / a; - g = (255 * g + (a / 2)) / a; - b = (255 * b + (a / 2)) / a; + r = static_cast<uint8_t>((255 * r + (a / 2)) / a); + g = static_cast<uint8_t>((255 * g + (a / 2)) / a); + b = static_cast<uint8_t>((255 * b + (a / 2)) / a); } } diff --git a/src/mbgl/util/tiny_sdf.cpp b/src/mbgl/util/tiny_sdf.cpp index 6edcd83bc2..a71d04386f 100644 --- a/src/mbgl/util/tiny_sdf.cpp +++ b/src/mbgl/util/tiny_sdf.cpp @@ -35,7 +35,7 @@ void edt1d(std::vector<double>& f, for (uint32_t q = 0, k = 0; q < n; q++) { while (z[k + 1] < q) k++; - d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]; + d[q] = (static_cast<double>(q) - v[k]) * (static_cast<double>(q) - v[k]) + f[v[k]]; } } |