diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index 15c0ae1d7..baec8a204 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -2933,6 +2933,7 @@ void InfoAboutArmy::initFromArmy(const CArmedInstance *Army, bool detailed) void InfoAboutHero::assign(const InfoAboutHero & iah) { + vstd::clear_pointer(details); InfoAboutArmy::operator = (iah); details = (iah.details ? new Details(*iah.details) : nullptr); @@ -2962,7 +2963,7 @@ InfoAboutHero::InfoAboutHero(const CGHeroInstance *h, InfoAboutHero::EInfoLevel InfoAboutHero::~InfoAboutHero() { - delete details; + vstd::clear_pointer(details); } InfoAboutHero & InfoAboutHero::operator=(const InfoAboutHero & iah) @@ -2973,6 +2974,7 @@ InfoAboutHero & InfoAboutHero::operator=(const InfoAboutHero & iah) void InfoAboutHero::initFromHero(const CGHeroInstance *h, InfoAboutHero::EInfoLevel infoLevel) { + vstd::clear_pointer(details); if(!h) return; @@ -3013,14 +3015,18 @@ InfoAboutTown::InfoAboutTown(): } -InfoAboutTown::InfoAboutTown(const CGTownInstance *t, bool detailed) +InfoAboutTown::InfoAboutTown(const CGTownInstance *t, bool detailed): + details(nullptr), + tType(nullptr), + built(0), + fortLevel(0) { initFromTown(t, detailed); } InfoAboutTown::~InfoAboutTown() { - delete details; + vstd::clear_pointer(details); } void InfoAboutTown::initFromTown(const CGTownInstance *t, bool detailed) @@ -3032,6 +3038,8 @@ void InfoAboutTown::initFromTown(const CGTownInstance *t, bool detailed) name = t->name; tType = t->town; + vstd::clear_pointer(details); + if(detailed) { //include details about hero