From 7cb7f158e1a1e548a70efd715b92991b59e0d0de Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Thu, 28 May 2020 17:52:29 +0300 Subject: [PATCH] [indexer] Prevent FeatureParams::m_geomType usage before initialization. --- indexer/feature_data.cpp | 6 +++--- indexer/feature_data.hpp | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp index 01e4ecdeb4..179fa60e9d 100644 --- a/indexer/feature_data.cpp +++ b/indexer/feature_data.cpp @@ -359,7 +359,7 @@ void FeatureParams::SetGeomTypePointEx() feature::GeomType FeatureParams::GetGeomType() const { CHECK(IsValid(), ()); - switch (m_geomType) + switch (*m_geomType) { case HeaderGeomType::Line: return GeomType::Line; case HeaderGeomType::Area: return GeomType::Area; @@ -370,7 +370,7 @@ feature::GeomType FeatureParams::GetGeomType() const HeaderGeomType FeatureParams::GetHeaderGeomType() const { CHECK(IsValid(), ()); - return m_geomType; + return *m_geomType; } void FeatureParams::SetRwSubwayType(char const * cityName) @@ -477,7 +477,7 @@ uint32_t FeatureParams::FindType(uint32_t comp, uint8_t level) const bool FeatureParams::IsValid() const { - if (m_types.empty() || m_types.size() > kMaxTypesCount) + if (m_types.empty() || m_types.size() > kMaxTypesCount || !m_geomType) return false; return FeatureParamsBase::IsValid(); diff --git a/indexer/feature_data.hpp b/indexer/feature_data.hpp index 6fa0f115bb..79b9bb6633 100644 --- a/indexer/feature_data.hpp +++ b/indexer/feature_data.hpp @@ -3,16 +3,17 @@ #include "indexer/feature_decl.hpp" #include "indexer/feature_meta.hpp" -#include "geometry/point2d.hpp" - #include "coding/reader.hpp" #include "coding/string_utf8_multilang.hpp" #include "coding/value_opt_string.hpp" +#include "geometry/point2d.hpp" + #include #include #include #include +#include #include #include #include @@ -288,7 +289,7 @@ private: static uint32_t GetIndexForType(uint32_t t); static uint32_t GetTypeForIndex(uint32_t i); - feature::HeaderGeomType m_geomType = feature::HeaderGeomType::Point; + std::optional m_geomType; }; class FeatureBuilderParams : public FeatureParams