From 9257deb68b2e3f5c50280d3811be70ee52ef9605 Mon Sep 17 00:00:00 2001 From: Arsenii es3n1n Date: Tue, 10 Sep 2024 21:07:38 +0200 Subject: [PATCH] fix: check m_pClassInfo for nullptr --- source2gen/src/sdk/sdk.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/source2gen/src/sdk/sdk.cpp b/source2gen/src/sdk/sdk.cpp index f2847ec..8b0824c 100644 --- a/source2gen/src/sdk/sdk.cpp +++ b/source2gen/src/sdk/sdk.cpp @@ -212,16 +212,16 @@ namespace { } while (pClass != nullptr); } - const auto has_non_standard_layout_field = - std::ranges::any_of(class_.GetFields() | std::ranges::views::transform([&](const SchemaClassFieldData_t& e) { - if (const auto* e_class = e.m_pSchemaType->GetAsDeclaredClass(); e_class != nullptr) { - return !IsStandardLayoutClass(cache, *e_class->m_pClassInfo); - } else { - // Everything that is not a class has no effect - return false; - } - }), - std::identity{}); + const auto has_non_standard_layout_field = std::ranges::any_of( + class_.GetFields() | std::ranges::views::transform([&](const SchemaClassFieldData_t& e) { + if (const auto* e_class = e.m_pSchemaType->GetAsDeclaredClass(); e_class != nullptr && e_class->m_pClassInfo != nullptr) { + return !IsStandardLayoutClass(cache, *e_class->m_pClassInfo); + } else { + // Everything that is not a class has no effect + return false; + } + }), + std::identity{}); if (has_non_standard_layout_field) { return cache.emplace(id, false).first->second; @@ -281,7 +281,7 @@ namespace { /// @return For class types, returns @ref GetClassAlignmentRecursive(). Otherwise returns the immediately available size. [[nodiscard]] std::optional GetAlignmentOfTypeRecursive(std::map>& cache, const CSchemaType& type) { - if (const auto* class_ = type.GetAsDeclaredClass(); class_ != nullptr) { + if (const auto* class_ = type.GetAsDeclaredClass(); class_ != nullptr && class_->m_pClassInfo != nullptr) { return GetClassAlignmentRecursive(cache, *class_->m_pClassInfo); } else { return type.GetSizeAndAlignment().and_then([](const auto& e) { return std::get<1>(e); });