1
0
forked from mirrors/0ad

Fix segfault from a formation infinite loop.

#5932 reported a segfault. The direct cause is an infinite loop in
Order.Repair in a formation controller.
There are multiple issues at play here, but the core problem is that the
controller has been marked for destruction, but remains alive over the
turn and UnitAI timers can fire. This leads to an unexpected state that
triggers an infinite loop.

To avoid this problem, immediately switch the formation controller to a
clean state when it's being disbanded.

Fixes #5932

Differential Revision: https://code.wildfiregames.com/D3410
This was SVN commit r24688.
This commit is contained in:
wraitii
2021-01-18 18:29:40 +00:00
parent 04240f05a7
commit c57a4d90a1
@@ -459,6 +459,9 @@ Formation.prototype.Disband = function()
this.formationMembersWithAura = [];
this.offsets = undefined;
let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI);
// Hack: switch to a clean state to stop timers.
cmpUnitAI.UnitFsm.SwitchToNextState(cmpUnitAI, "");
Engine.DestroyEntity(this.entity);
};