Fix access violation in proplist-to-static conversion

console-destruction
Sven Eberhardt 2016-09-06 01:09:29 -04:00
parent 282a561462
commit dee6086e1d
1 changed files with 8 additions and 2 deletions

View File

@ -294,8 +294,14 @@ C4PropListStatic *C4PropList::FreezeAndMakeStaticRecursively(const C4PropListSta
this_static = NewStatic(GetPrototype(), parent, key);
this_static->Properties.Swap(&Properties); // grab properties
this_static->Status = Status;
while (FirstRef) FirstRef->SetPropList(this_static);
// Now "this" should be deleted.
C4Value holder = C4VPropList(this);
while (FirstRef && FirstRef->NextRef)
{
C4Value *ref = FirstRef;
if (ref == &holder) ref = ref->NextRef;
ref->SetPropList(this_static);
}
// "this" should be deleted as holder goes out of scope
}
// Iterate over sorted list of elements to make static
// Must iterate over sorted list because the order must be defined, just in case it's a network game