diff --git a/CHANGELOG.md b/CHANGELOG.md index a4f6651..9f2647c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.34.6 + +* Fix crash when there are null entries in the metadata table + ## 1.34.5 * Fix line numbers in GeoJSON feature parsing error messages diff --git a/decode.cpp b/decode.cpp index e75248c..6a0b677 100644 --- a/decode.cpp +++ b/decode.cpp @@ -306,17 +306,17 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set co const unsigned char *name = sqlite3_column_text(stmt2, 0); const unsigned char *value = sqlite3_column_text(stmt2, 1); + if (name == NULL || value == NULL) { + fprintf(stderr, "Corrupt mbtiles file: null metadata\n"); + exit(EXIT_FAILURE); + } + if (exclude_meta.count((char *) name) == 0) { if (within) { state.json_comma_newline(); } within = 1; - if (name == NULL || value == NULL) { - fprintf(stderr, "Corrupt mbtiles file: null metadata\n"); - exit(EXIT_FAILURE); - } - state.json_write_string((char *) name); state.json_write_string((char *) value); } @@ -413,6 +413,11 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set co ty = (1LL << tz) - 1 - ty; const char *s = (const char *) sqlite3_column_blob(stmt, 0); + if (s == NULL) { + fprintf(stderr, "Corrupt mbtiles file: null entry in tiles table\n"); + exit(EXIT_FAILURE); + } + handle(std::string(s, len), tz, tx, ty, to_decode, pipeline, stats, state); } @@ -449,6 +454,11 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set co int len = sqlite3_column_bytes(stmt, 0); const char *s = (const char *) sqlite3_column_blob(stmt, 0); + if (s == NULL) { + fprintf(stderr, "Corrupt mbtiles file: null entry in tiles table\n"); + exit(EXIT_FAILURE); + } + if (z != oz) { fprintf(stderr, "%s: Warning: using tile %d/%u/%u instead of %d/%u/%u\n", fname, z, x, y, oz, ox, oy); } diff --git a/version.hpp b/version.hpp index 7adab3e..a1f8a52 100644 --- a/version.hpp +++ b/version.hpp @@ -1,6 +1,6 @@ #ifndef VERSION_HPP #define VERSION_HPP -#define VERSION "v1.34.5" +#define VERSION "v1.34.6" #endif