From 29ef5210a7164a5ecb0818ea6d0e05b0b84cdabb Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 18 Jan 2022 12:17:13 +0000 Subject: [PATCH] Fix crash when no waypt controller is created When we don't build any wapy controller, also bail out, rather than crashing. Jonathan could trigger this with an empty route on the A320, although no stand-alone test-case so far. SF-ID: https://sourceforge.net/p/flightgear/codetickets/2695/ --- src/Instrumentation/gps.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 0fa026041..7de8d0d5f 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -784,7 +784,7 @@ void GPS::wp1Changed() _wayptController.reset(new DirectToController(this, _currentWaypt, _wp0_position)); } - const bool ok = _wayptController->init(); + const bool ok = _wayptController && _wayptController->init(); if (!ok) { SG_LOG(SG_AUTOPILOT, SG_WARN, "GPS failed to init RNAV controller for waypoint " << _currentWaypt->ident()); _wayptController.reset();