diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2018-06-11 14:02:15 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2018-06-12 10:55:46 +0200 |
commit | 9af5172f98a4319ba4d8d9d4cb7a24ac8bd9ea12 (patch) | |
tree | 21e315d8aea8439947b142c4ef6dcd4c5d34fbbb /src/mbgl/geometry | |
parent | ed7623092515f264ab4dc8e8dc7f493ecfd67a6c (diff) | |
download | qtlocation-mapboxgl-9af5172f98a4319ba4d8d9d4cb7a24ac8bd9ea12.tar.gz |
[core] fix undefined behavior in LineAtlas::addDash
Diffstat (limited to 'src/mbgl/geometry')
-rw-r--r-- | src/mbgl/geometry/line_atlas.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp index 71a855b943..1129bd0b20 100644 --- a/src/mbgl/geometry/line_atlas.cpp +++ b/src/mbgl/geometry/line_atlas.cpp @@ -41,6 +41,10 @@ LinePatternPos LineAtlas::addDash(const std::vector<float>& dasharray, LinePatte const uint8_t dashheight = 2 * n + 1; const uint8_t offset = 128; + if (dasharray.size() < 2) { + return LinePatternPos(); + } + if (nextRow + dashheight > image.size.height) { Log::Warning(Event::OpenGL, "line atlas bitmap overflow"); return LinePatternPos(); @@ -73,6 +77,9 @@ LinePatternPos LineAtlas::addDash(const std::vector<float>& dasharray, LinePatte while (right < x / stretch) { left = right; + if (partIndex >= dasharray.size()) { + return LinePatternPos(); + } right = right + dasharray[partIndex]; if (oddLength && partIndex == dasharray.size() - 1) { |