summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-06-06 10:40:16 +0000
committerfrosch <frosch@openttd.org>2009-06-06 10:40:16 +0000
commit0b8ceb3007c018954203519b3768c45b3fa21920 (patch)
treee5d95131855dee077ef541c68cf2a2d56d0bac88 /src
parent59ae226ab1adf57f42075fa834237bd18c1b0adb (diff)
downloadopenttd-0b8ceb3007c018954203519b3768c45b3fa21920.tar.xz
(svn r16523) -Fix (rNewPool): Segfault when small ufos were heading for deleted vehicles.
Diffstat (limited to 'src')
-rw-r--r--src/disaster_cmd.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index 3cc62d057..91208520b 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -314,7 +314,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
} else {
/* Target a vehicle */
Vehicle *u_tmp = Vehicle::Get(v->dest_tile);
- if (u_tmp->type != VEH_ROAD || !IsRoadVehFront(u_tmp)) {
+ if (u_tmp == NULL || u_tmp->type != VEH_ROAD || !IsRoadVehFront(u_tmp)) {
delete v;
return false;
}
@@ -402,7 +402,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, boo
if (v->current_order.GetDestination() == 2) {
if (GB(v->tick_counter, 0, 2) == 0) {
- Industry *i = Industry::Get(v->dest_tile);
+ Industry *i = Industry::Get(v->dest_tile); // Industry destructor calls ReleaseDisastersTargetingIndustry, so this is valid
int x = TileX(i->xy) * TILE_SIZE;
int y = TileY(i->xy) * TILE_SIZE;
uint32 r = Random();
@@ -420,7 +420,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, boo
v->current_order.SetDestination(2);
v->age = 0;
- Industry *i = Industry::Get(v->dest_tile);
+ Industry *i = Industry::Get(v->dest_tile); // Industry destructor calls ReleaseDisastersTargetingIndustry, so this is valid
DestructIndustry(i);
SetDParam(0, i->town->index);