diff --git a/cpp/map_closures/MapClosures.cpp b/cpp/map_closures/MapClosures.cpp index a6f8c62..85d34dd 100644 --- a/cpp/map_closures/MapClosures.cpp +++ b/cpp/map_closures/MapClosures.cpp @@ -110,7 +110,12 @@ void MapClosures::MatchAndAddToDatabase(const int id, } ClosureCandidate MapClosures::ValidateClosure(const int reference_id, const int query_id) const { - const Tree::MatchVector &matches = descriptor_matches_.at(reference_id); + const auto it = descriptor_matches_.find(reference_id); + if (it == descriptor_matches_.end()) { + return ClosureCandidate(); + } + + const Tree::MatchVector &matches = it->second; const size_t num_matches = matches.size(); ClosureCandidate closure;