diff --git a/indexer/classificator.hpp b/indexer/classificator.hpp index 2db65bb822..c823e161e9 100644 --- a/indexer/classificator.hpp +++ b/indexer/classificator.hpp @@ -195,6 +195,7 @@ public: //@} uint32_t GetIndexForType(uint32_t t) const { return m_mapping.GetIndex(t); } + // Throws std::out_of_range exception. uint32_t GetTypeForIndex(uint32_t i) const { return m_mapping.GetType(i); } bool IsTypeValid(uint32_t t) const { return m_mapping.HasIndex(t); } diff --git a/indexer/feature_loader.cpp b/indexer/feature_loader.cpp index 14beac5e6f..57c25819ee 100644 --- a/indexer/feature_loader.cpp +++ b/indexer/feature_loader.cpp @@ -11,6 +11,7 @@ #include "base/logging.hpp" #include "std/algorithm.hpp" +#include "std/exception.hpp" #include "std/limits.hpp" #include "defines.hpp" @@ -29,8 +30,23 @@ void LoaderCurrent::ParseTypes() ArrayByteSource source(DataPtr() + m_TypesOffset); size_t const count = m_pF->GetTypesCount(); - for (size_t i = 0; i < count; ++i) - m_pF->m_types[i] = c.GetTypeForIndex(ReadVarUint(source)); + uint32_t index = 0; + try + { + for (size_t i = 0; i < count; ++i) + { + index = ReadVarUint(source); + m_pF->m_types[i] = c.GetTypeForIndex(index); + } + } + catch (std::out_of_range const & ex) + { + LOG(LERROR, ("Incorrect type index for feature. FeatureID:", m_pF->m_id, + ". Incorrect index:", index, ". Loaded feature types:", m_pF->m_types, + ". Total count of types:", count, ". Header:", m_pF->m_header, + ". Exception:", ex.what())); + throw; + } m_CommonOffset = CalcOffset(source); } diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index 6813dd783f..7f775b955a 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -33,7 +33,7 @@ string DebugPrint(MwmSet::MwmId const & id) { ostringstream ss; if (id.m_info.get()) - ss << "MwmId [" << id.m_info->GetCountryName() << "]"; + ss << "MwmId [" << id.m_info->GetCountryName() << ", " << id.m_info->GetVersion() << "]"; else ss << "MwmId [invalid]"; return ss.str(); diff --git a/indexer/types_mapping.hpp b/indexer/types_mapping.hpp index 1b3b9d1bad..321258e7f6 100644 --- a/indexer/types_mapping.hpp +++ b/indexer/types_mapping.hpp @@ -19,10 +19,11 @@ public: void Clear(); void Load(istream & s); + // Throws std::out_of_range exception. uint32_t GetType(uint32_t ind) const { ASSERT_LESS ( ind, m_types.size(), () ); - return m_types[ind]; + return m_types.at(ind); } uint32_t GetIndex(uint32_t t) const;