Fix overflow when iterating through 0-length lists backwards

This commit is contained in:
Eric Fischer
2017-11-17 15:47:10 -08:00
parent 6fd4918c4d
commit 9a12a76855
3 changed files with 4 additions and 3 deletions
+1
View File
@@ -3,6 +3,7 @@
* Add tippecanoe-json-tool for sorting and joining GeoJSON files * Add tippecanoe-json-tool for sorting and joining GeoJSON files
* Fix problem where --detect-shared-borders could simplify polygons away * Fix problem where --detect-shared-borders could simplify polygons away
* Attach --coalesce-smallest-as-needed leftovers to the last feature, not the first * Attach --coalesce-smallest-as-needed leftovers to the last feature, not the first
* Fix overflow when iterating through 0-length lists backwards
## 1.26.7 ## 1.26.7
+2 -2
View File
@@ -515,7 +515,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
for (ssize_t i = sf.full_keys.size() - 1; i >= 0; i--) { for (ssize_t i = (ssize_t) sf.full_keys.size() - 1; i >= 0; i--) {
if (sst->exclude_all) { if (sst->exclude_all) {
if (sst->include->count(sf.full_keys[i]) == 0) { if (sst->include->count(sf.full_keys[i]) == 0) {
sf.full_keys.erase(sf.full_keys.begin() + i); sf.full_keys.erase(sf.full_keys.begin() + i);
@@ -569,7 +569,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
} }
} }
for (ssize_t i = sf.full_keys.size() - 1; i >= 0; i--) { for (ssize_t i = (ssize_t) sf.full_keys.size() - 1; i >= 0; i--) {
if (sf.full_values[i].type == mvt_null) { if (sf.full_values[i].type == mvt_null) {
sf.full_keys.erase(sf.full_keys.begin() + i); sf.full_keys.erase(sf.full_keys.begin() + i);
sf.full_values.erase(sf.full_values.begin() + i); sf.full_values.erase(sf.full_values.begin() + i);
+1 -1
View File
@@ -1631,7 +1631,7 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
} }
// Attach any pieces that were waiting to be coalesced onto some features that did make it. // Attach any pieces that were waiting to be coalesced onto some features that did make it.
for (ssize_t i = coalesced_geometry.size() - 1; i >= 0; i--) { for (ssize_t i = (ssize_t) coalesced_geometry.size() - 1; i >= 0; i--) {
for (ssize_t j = partials.size() - 1; j >= 0; j--) { for (ssize_t j = partials.size() - 1; j >= 0; j--) {
if (partials[j].layer == coalesced_geometry[i].layer && partials[j].t == coalesced_geometry[i].t) { if (partials[j].layer == coalesced_geometry[i].layer && partials[j].t == coalesced_geometry[i].t) {
for (size_t k = 0; k < coalesced_geometry[i].geometry.size(); k++) { for (size_t k = 0; k < coalesced_geometry[i].geometry.size(); k++) {