avoid free-cycle

This commit is contained in:
Tim Felgentreff 2022-07-05 07:43:16 +02:00
parent 379567fcb0
commit 94a6d9ecd9

View file

@ -553,21 +553,26 @@ void CUnit::Release(bool final)
// removed, but fog of war calculations are still underway, where we want to // removed, but fog of war calculations are still underway, where we want to
// read a BoolFlag; there are more instances of this...) // read a BoolFlag; there are more instances of this...)
for (std::vector<COrder *>::iterator order = Orders.begin(); order != Orders.end(); ++order) { for (std::vector<COrder *>::iterator order = Orders.begin(); order != Orders.end(); ++order) {
delete *order; COrder *orderToDelete = *order;
*order = NULL;
delete orderToDelete;
} }
Orders.clear(); Orders.clear();
if (SavedOrder != NULL) { if (SavedOrder != NULL) {
delete SavedOrder; COrder *order = SavedOrder;
SavedOrder = NULL; SavedOrder = NULL;
delete order;
} }
if (NewOrder != NULL) { if (NewOrder != NULL) {
delete NewOrder; COrder *order = NewOrder;
NewOrder = NULL; NewOrder = NULL;
delete order;
} }
if (CriticalOrder != NULL) { if (CriticalOrder != NULL) {
delete CriticalOrder; COrder *order = CriticalOrder;
CriticalOrder = NULL; CriticalOrder = NULL;
delete order;
} }
// Remove the unit from the global units table. // Remove the unit from the global units table.