From 6929429f0f6ca0b623aff96cb455bcbc80c0ba47 Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Sat, 2 Nov 2019 13:24:38 +0000 Subject: Fix ccb4c37: Use of possibly uninitialised pointer (#7818) --- src/aircraft_cmd.cpp | 8 ++++---- 1 file 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; } -- cgit v1.2.3-70-g09d2