- fixed: When deserializing the object list, the array must be nulled before using it so that a premature abort does not end up working on random data.

This commit is contained in:
Christoph Oelckers 2018-05-29 19:00:41 +02:00
parent f06ee10495
commit ad343892f3

View file

@ -989,6 +989,11 @@ void FSerializer::ReadObjects(bool hubtravel)
{ {
DThinker::bSerialOverride = true; DThinker::bSerialOverride = true;
r->mDObjects.Resize(ArraySize()); r->mDObjects.Resize(ArraySize());
for (auto &p : r->mDObjects)
{
p = nullptr;
}
// First iteration: create all the objects but do nothing with them yet. // First iteration: create all the objects but do nothing with them yet.
for (unsigned i = 0; i < r->mDObjects.Size(); i++) for (unsigned i = 0; i < r->mDObjects.Size(); i++)
{ {
@ -1060,7 +1065,7 @@ void FSerializer::ReadObjects(bool hubtravel)
// nuke all objects we created here. // nuke all objects we created here.
for (auto obj : r->mDObjects) for (auto obj : r->mDObjects)
{ {
if (!(obj->ObjectFlags & OF_EuthanizeMe)) obj->Destroy(); if (obj != nullptr && !(obj->ObjectFlags & OF_EuthanizeMe)) obj->Destroy();
} }
r->mDObjects.Clear(); r->mDObjects.Clear();