- fixed several Destroy methods which blanketly assumed that the object's pointers were valid to use without checks.

This is not the case if deserialization prematurely aborts. The entire object may be invalid if something in the deserializer I_Error's out.
This commit is contained in:
Christoph Oelckers 2016-09-23 08:49:30 +02:00
parent 657140f985
commit cad2be46ac
4 changed files with 57 additions and 34 deletions

View file

@ -116,13 +116,16 @@ void DBaseDecal::Destroy ()
void DBaseDecal::Remove ()
{
if (WallPrev == nullptr) Side->AttachedDecals = WallNext;
if (WallPrev == nullptr)
{
if (Side != nullptr) Side->AttachedDecals = WallNext;
}
else WallPrev->WallNext = WallNext;
if (WallNext != nullptr) WallNext->WallPrev = WallPrev;
WallPrev = NULL;
WallNext = NULL;
WallPrev = nullptr;
WallNext = nullptr;
}
void DBaseDecal::Serialize(FSerializer &arc)

View file

@ -48,6 +48,8 @@ bool ASectorAction::IsActivatedByUse() const
}
void ASectorAction::Destroy ()
{
if (Sector != nullptr)
{
// Remove ourself from this sector's list of actions
AActor *probe = Sector->SecActTarget;
@ -63,10 +65,11 @@ void ASectorAction::Destroy ()
prev.act = &probe->tracer;
probe = probe->tracer;
}
if (probe != NULL)
if (probe != nullptr)
{
*prev.act = probe->tracer;
}
}
Super::Destroy ();
}

View file

@ -169,8 +169,11 @@ void ASectorSilencer::BeginPlay ()
}
void ASectorSilencer::Destroy ()
{
if (Sector != nullptr)
{
Sector->Flags &= ~SECF_SILENT;
}
Super::Destroy ();
}

View file

@ -417,16 +417,19 @@ DSectorPlaneInterpolation::DSectorPlaneInterpolation(sector_t *_sector, bool _pl
//==========================================================================
void DSectorPlaneInterpolation::Destroy()
{
if (sector != nullptr)
{
if (ceiling)
{
sector->interpolations[sector_t::CeilingMove] = NULL;
sector->interpolations[sector_t::CeilingMove] = nullptr;
}
else
{
sector->interpolations[sector_t::FloorMove] = NULL;
sector->interpolations[sector_t::FloorMove] = nullptr;
}
sector = nullptr;
}
for(unsigned i=0; i<attached.Size(); i++)
{
attached[i]->DelRef();
@ -592,14 +595,18 @@ DSectorScrollInterpolation::DSectorScrollInterpolation(sector_t *_sector, bool _
//==========================================================================
void DSectorScrollInterpolation::Destroy()
{
if (sector != nullptr)
{
if (ceiling)
{
sector->interpolations[sector_t::CeilingScroll] = NULL;
sector->interpolations[sector_t::CeilingScroll] = nullptr;
}
else
{
sector->interpolations[sector_t::FloorScroll] = NULL;
sector->interpolations[sector_t::FloorScroll] = nullptr;
}
sector = nullptr;
}
Super::Destroy();
}
@ -694,7 +701,11 @@ DWallScrollInterpolation::DWallScrollInterpolation(side_t *_side, int _part)
void DWallScrollInterpolation::Destroy()
{
side->textures[part].interpolation = NULL;
if (side != nullptr)
{
side->textures[part].interpolation = nullptr;
side = nullptr;
}
Super::Destroy();
}
@ -788,7 +799,10 @@ DPolyobjInterpolation::DPolyobjInterpolation(FPolyObj *po)
void DPolyobjInterpolation::Destroy()
{
poly->interpolation = NULL;
if (poly != nullptr)
{
poly->interpolation = nullptr;
}
Super::Destroy();
}