From e07a4dd51b2dfbe3a57f3be36ecba1b3c9c213b2 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 18 Jan 2018 12:10:47 -0800 Subject: [PATCH] Fix out-of-bounds error when no threads were needed for a zoom level --- .travis.yml | 2 +- tests/onefeature/-zg_--drop-densest-as-needed.json | 13 +++++++++++++ tests/onefeature/in.json | 1 + tile.cpp | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/onefeature/-zg_--drop-densest-as-needed.json create mode 100644 tests/onefeature/in.json diff --git a/.travis.yml b/.travis.yml index cd905ff..c44d170 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ matrix: # debug+leak+address-sanitizer build - os: linux compiler: clang - env: CLANG_VERSION='3.8.0' BUILDTYPE=Debug ASAN_OPTIONS=detect_leaks=1 CC="clang-3.8" CXX="clang++-3.8" CXXFLAGS="-fsanitize=address" CFLAGS="-fsanitize=address" LDFLAGS="-fsanitize=address" FEWER=true + env: CLANG_VERSION='3.8.0' BUILDTYPE=Debug ASAN_OPTIONS=detect_leaks=1 CC="clang-3.8" CXX="clang++-3.8" CXXFLAGS="-fsanitize=address,undefined" CFLAGS="-fsanitize=address,undefined" LDFLAGS="-fsanitize=address,undefined" FEWER=true addons: apt: sources: ['ubuntu-toolchain-r-test' ] diff --git a/tests/onefeature/-zg_--drop-densest-as-needed.json b/tests/onefeature/-zg_--drop-densest-as-needed.json new file mode 100644 index 0000000..da418e6 --- /dev/null +++ b/tests/onefeature/-zg_--drop-densest-as-needed.json @@ -0,0 +1,13 @@ +{ "type": "FeatureCollection", "properties": { +"bounds": "-180.000000,0.800000,180.000000,1.000000", +"center": "-179.989014,1.000000,14", +"description": "tests/onefeature/-zg_--drop-densest-as-needed.json.check.mbtiles", +"format": "pbf", +"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 14, \"fields\": {} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 1,\"geometry\": \"LineString\",\"attributeCount\": 0,\"attributes\": []}]}}", +"maxzoom": "14", +"minzoom": "0", +"name": "tests/onefeature/-zg_--drop-densest-as-needed.json.check.mbtiles", +"type": "overlay", +"version": "2" +}, "features": [ +] } diff --git a/tests/onefeature/in.json b/tests/onefeature/in.json new file mode 100644 index 0000000..4d140e9 --- /dev/null +++ b/tests/onefeature/in.json @@ -0,0 +1 @@ +{"":"","":[{"":"","":{"":[]},"":{"":""}},{"":"","type":"LineString","coordinates":[[1000,0.8],[900,1]]} diff --git a/tile.cpp b/tile.cpp index 3119c32..18b09d8 100644 --- a/tile.cpp +++ b/tile.cpp @@ -2363,6 +2363,9 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo if (threads >= (1U << 30)) { threads = 1U << 30; } + if (threads < 1) { + threads = 1; + } // Assign temporary files to threads