From 942f8bbf058c59aab091455771f0dfbbc3420d98 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Thu, 10 Aug 2023 21:18:52 +0300 Subject: [PATCH] Fix possible access to non-existing building --- lib/mapObjects/CGTownInstance.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 4f088b414..10fd30409 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -996,6 +996,12 @@ CBuilding::TRequired CGTownInstance::genBuildingRequirements(const BuildingID & std::function dependTest = [&](const BuildingID & id) -> CBuilding::TRequired::Variant { + if (town->buildings.count(id) == 0) + { + logMod->error("Invalid building ID %d in building dependencies!", id.getNum()); + return CBuilding::TRequired::OperatorAll(); + } + const CBuilding * build = town->buildings.at(id); CBuilding::TRequired::OperatorAll requirements;