c++: fix off-by-one error causing out-of-bounds access

This commit is contained in:
Brandon Liu
2023-05-03 12:58:29 +08:00
parent 9b0e473d30
commit 7ea69442b3
2 changed files with 12 additions and 1 deletions

View File

@@ -484,7 +484,7 @@ inline std::tuple<std::string, std::string, int> build_root_leaves(const std::fu
std::vector<pmtiles::entryv3> root_entries;
std::string leaves_bytes;
int num_leaves = 0;
for (size_t i = 0; i <= entries.size(); i += leaf_size) {
for (size_t i = 0; i < entries.size(); i += leaf_size) {
num_leaves++;
int end = i + leaf_size;
if (i + leaf_size > entries.size()) {