Fix heap use after free when removing oil rig

This commit is contained in:
Jonathan G Rennison
2019-11-02 20:55:14 +00:00
parent e7170463f0
commit fe4fa46da3
2 changed files with 7 additions and 1 deletions

View File

@@ -4390,6 +4390,10 @@ void DeleteOilRig(TileIndex tile)
MakeWaterKeepingClass(tile, OWNER_NONE);
assert(st->facilities == (FACIL_AIRPORT | FACIL_DOCK) && st->airport.type == AT_OILRIG);
if (st->industry != nullptr && st->industry->neutral_station == st) {
/* Don't leave dangling neutral station pointer */
st->industry->neutral_station = nullptr;
}
delete st;
}