diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp index 7485ef31a..5cfb67021 100644 --- a/src/mbgl/geometry/line_atlas.cpp +++ b/src/mbgl/geometry/line_atlas.cpp @@ -33,7 +33,6 @@ LinePatternPos LineAtlas::getDashPosition(const std::vector &dasharray, b std::string key = sskey.str(); if (positions.find(key) == positions.end()) { - //fprintf(stderr, "add %s\n", key.c_str()); positions[key] = addDash(dasharray, round); } @@ -46,7 +45,10 @@ LinePatternPos LineAtlas::addDash(const std::vector &dasharray, bool roun int dashheight = 2 * n + 1; const uint8_t offset = 128; - // TODO check if enough space + if (nextRow + dashheight > height) { + fprintf(stderr, "[WARNING] line atlas bitmap overflow\n"); + return LinePatternPos(); + } float length = 0; for (const float &part : dasharray) { diff --git a/src/mbgl/geometry/line_atlas.hpp b/src/mbgl/geometry/line_atlas.hpp index 329c907b1..191dc0c4d 100644 --- a/src/mbgl/geometry/line_atlas.hpp +++ b/src/mbgl/geometry/line_atlas.hpp @@ -32,7 +32,7 @@ private: char *const data = nullptr; std::atomic dirty; uint32_t texture = 0; - uint32_t nextRow = 0; + int nextRow = 0; std::map positions; };