- do not pass TObjPtr<> instances as ScriptUtil::Exec() arguments

There was no read barrier inserted for AActor object while it's a subject of garbage collection
Pointer stored in TObjPtr<> was reinterpreted as void* because of vararg function

https://forum.zdoom.org/viewtopic.php?t=64771
This commit is contained in:
alexey.lysiuk 2019-05-22 17:32:33 +03:00 committed by Christoph Oelckers
parent 34a13cae04
commit a04d79d871
2 changed files with 14 additions and 9 deletions

View File

@ -201,7 +201,12 @@ public:
o = nullptr;
return *this;
}
T Get() throw()
{
return GC::ReadBarrier(pp);
}
operator T() throw()
{
return GC::ReadBarrier(pp);

View File

@ -9096,7 +9096,7 @@ scriptwait:
break;
case PCD_CLEARINVENTORY:
ScriptUtil::Exec(NAME_ClearInventory, ScriptUtil::Pointer, activator, ScriptUtil::End);
ScriptUtil::Exec(NAME_ClearInventory, ScriptUtil::Pointer, activator.Get(), ScriptUtil::End);
break;
case PCD_CLEARACTORINVENTORY:
@ -9119,7 +9119,7 @@ scriptwait:
case PCD_GIVEINVENTORY:
{
int typeindex = FName(Level->Behaviors.LookupString(STACK(2))).GetIndex();
ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End);
ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End);
sp -= 2;
break;
}
@ -9148,7 +9148,7 @@ scriptwait:
case PCD_GIVEINVENTORYDIRECT:
{
int typeindex = FName(Level->Behaviors.LookupString(TAGSTR(uallong(pc[0])))).GetIndex();
ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, uallong(pc[1]), ScriptUtil::End);
ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, typeindex, ScriptUtil::Int, uallong(pc[1]), ScriptUtil::End);
pc += 2;
break;
}
@ -9156,7 +9156,7 @@ scriptwait:
case PCD_TAKEINVENTORY:
{
int typeindex = FName(Level->Behaviors.LookupString(STACK(2))).GetIndex();
ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End);
ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End);
sp -= 2;
break;
}
@ -9185,7 +9185,7 @@ scriptwait:
case PCD_TAKEINVENTORYDIRECT:
{
int typeindex = FName(Level->Behaviors.LookupString(TAGSTR(uallong(pc[0])))).GetIndex();
ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, uallong(pc[1]), ScriptUtil::End);
ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, typeindex, ScriptUtil::Int, uallong(pc[1]), ScriptUtil::End);
pc += 2;
break;
}
@ -9617,16 +9617,16 @@ scriptwait:
break;
case PCD_SETWEAPON:
STACK(1) = ScriptUtil::Exec(NAME_SetWeapon, ScriptUtil::Pointer, activator, ScriptUtil::Class, GetClassForIndex(STACK(1)), ScriptUtil::End);
STACK(1) = ScriptUtil::Exec(NAME_SetWeapon, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Class, GetClassForIndex(STACK(1)), ScriptUtil::End);
break;
case PCD_SETMARINEWEAPON:
ScriptUtil::Exec(NAME_SetMarineWeapon, ScriptUtil::Pointer, Level, ScriptUtil::Pointer, activator, ScriptUtil::Int, STACK(2), ScriptUtil::Int, STACK(1), ScriptUtil::End);
ScriptUtil::Exec(NAME_SetMarineWeapon, ScriptUtil::Pointer, Level, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, STACK(2), ScriptUtil::Int, STACK(1), ScriptUtil::End);
sp -= 2;
break;
case PCD_SETMARINESPRITE:
ScriptUtil::Exec(NAME_SetMarineSprite, ScriptUtil::Pointer, Level, ScriptUtil::Pointer, activator, ScriptUtil::Int, STACK(2), ScriptUtil::Class, GetClassForIndex(STACK(1)), ScriptUtil::End);
ScriptUtil::Exec(NAME_SetMarineSprite, ScriptUtil::Pointer, Level, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, STACK(2), ScriptUtil::Class, GetClassForIndex(STACK(1)), ScriptUtil::End);
sp -= 2;
break;