[ios, macos] Fix MGLOfflinePack invalidate crash (#15582)

This commit is contained in:
Julian Rex
2019-09-18 18:13:07 -04:00
committed by GitHub
parent 7bca176bea
commit 2b08c1d7bf
12 changed files with 354 additions and 14 deletions

View File

@@ -124,6 +124,10 @@ void OfflineDatabase::handleError(const util::IOException& ex, const char* actio
Log::Error(Event::Database, ex.code, "Can't %s: %s", action, ex.what());
}
void OfflineDatabase::handleError(const std::runtime_error& ex, const char* action) {
Log::Error(Event::Database, -1, "Can't %s: %s", action, ex.what());
}
void OfflineDatabase::removeExisting() {
Log::Warning(Event::Database, "Removing existing incompatible offline database");
@@ -1059,6 +1063,11 @@ expected<OfflineRegionDefinition, std::exception_ptr> OfflineDatabase::getRegion
} catch (const mapbox::sqlite::Exception& ex) {
handleError(ex, "load region");
return unexpected<std::exception_ptr>(std::current_exception());
} catch (const std::runtime_error& ex) {
// Catch errors from malformed offline region definitions
// and skip them (as above).
handleError(ex, "load region");
return unexpected<std::exception_ptr>(std::current_exception());
}
expected<OfflineRegionStatus, std::exception_ptr> OfflineDatabase::getRegionCompletedStatus(int64_t regionID) try {