Fix bd2649c1: Use after free in group GUI when removing vehicle

This commit is contained in:
Jonathan G Rennison
2020-10-14 18:06:31 +01:00
parent d85a529f87
commit 0c0c6c7531

View File

@@ -587,9 +587,10 @@ public:
{ {
/* If we select the all vehicles, this->list will contain all vehicles of the owner /* If we select the all vehicles, this->list will contain all vehicles of the owner
* else this->list will contain all vehicles which belong to the selected group */ * else this->list will contain all vehicles which belong to the selected group */
if (this->vehicles.NeedRebuild()) this->RecalculateInfoTotals(); bool recalculate_totals = this->vehicles.NeedRebuild();
this->BuildVehicleList(); this->BuildVehicleList();
this->SortVehicleList(); this->SortVehicleList();
if (recalculate_totals) this->RecalculateInfoTotals();
this->BuildGroupList(this->owner); this->BuildGroupList(this->owner);
@@ -1044,7 +1045,7 @@ public:
if (this->groups.NeedResort() || this->vehicles.NeedResort()) { if (this->groups.NeedResort() || this->vehicles.NeedResort()) {
this->SetWidgetDirty(WID_GL_LIST_VEHICLE); this->SetWidgetDirty(WID_GL_LIST_VEHICLE);
} }
if (this->RecalculateInfoTotals()) { if (!this->vehicles.NeedRebuild() && this->RecalculateInfoTotals()) {
this->SetWidgetDirty(WID_GL_INFO); this->SetWidgetDirty(WID_GL_INFO);
} }
} }