summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2019-11-02 13:24:38 +0000
committerGitHub <noreply@github.com>2019-11-02 13:24:38 +0000
commit6929429f0f6ca0b623aff96cb455bcbc80c0ba47 (patch)
treef943595ee84dd72a2ef8caeab8909c9a92bddad3 /src
parent729caa135b69278291cd38e75c97b414d4867d69 (diff)
downloadopenttd-6929429f0f6ca0b623aff96cb455bcbc80c0ba47.tar.xz
Fix ccb4c37: Use of possibly uninitialised pointer (#7818)
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_cmd.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index c3347c528..232fefcd7 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -129,8 +129,8 @@ static StationID FindNearestHangar(const Aircraft *v)
uint max_range = v->acache.cached_max_range_sqr;
/* Determine destinations where it's coming from and where it's heading to */
- const Station *last_dest;
- const Station *next_dest;
+ const Station *last_dest = nullptr;
+ const Station *next_dest = nullptr;
if (max_range != 0) {
if (v->current_order.IsType(OT_GOTO_STATION) ||
(v->current_order.IsType(OT_GOTO_DEPOT) && v->current_order.GetDepotActionType() != ODATFB_NEAREST_DEPOT)) {
@@ -155,8 +155,8 @@ static StationID FindNearestHangar(const Aircraft *v)
/* Check if our last and next destinations can be reached from the depot airport. */
if (max_range != 0) {
- uint last_dist = last_dest != nullptr && last_dest->airport.tile != INVALID_TILE ? DistanceSquare(st->airport.tile, last_dest->airport.tile) : 0;
- uint next_dist = next_dest != nullptr && next_dest->airport.tile != INVALID_TILE ? DistanceSquare(st->airport.tile, next_dest->airport.tile) : 0;
+ uint last_dist = (last_dest != nullptr && last_dest->airport.tile != INVALID_TILE) ? DistanceSquare(st->airport.tile, last_dest->airport.tile) : 0;
+ uint next_dist = (next_dest != nullptr && next_dest->airport.tile != INVALID_TILE) ? DistanceSquare(st->airport.tile, next_dest->airport.tile) : 0;
if (last_dist > max_range || next_dist > max_range) continue;
}