From: jmt Date: Wed, 9 Dec 2009 18:16:36 +0000 (+0000) Subject: Fix reset crash, thanks to Joe: make findNextWithPartial, and the route-manager,... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c453d1a0cc3010b7169889ce76ad42a0938b64ea;p=flightgear.git Fix reset crash, thanks to Joe: make findNextWithPartial, and the route-manager, robust about people setting NULL / empty airport idents. --- diff --git a/src/Autopilot/route_mgr.cxx b/src/Autopilot/route_mgr.cxx index 313cd33ed..bbd2db96b 100644 --- a/src/Autopilot/route_mgr.cxx +++ b/src/Autopilot/route_mgr.cxx @@ -775,7 +775,11 @@ const char* FGRouteMgr::getDepartureName() const void FGRouteMgr::setDepartureICAO(const char* aIdent) { - _departure = FGAirport::findByIdent(aIdent); + if ((aIdent == NULL) || (strlen(aIdent) < 4)) { + _departure = NULL; + } else { + _departure = FGAirport::findByIdent(aIdent); + } } const char* FGRouteMgr::getDestinationICAO() const @@ -798,6 +802,10 @@ const char* FGRouteMgr::getDestinationName() const void FGRouteMgr::setDestinationICAO(const char* aIdent) { - _destination = FGAirport::findByIdent(aIdent); + if ((aIdent == NULL) || (strlen(aIdent) < 4)) { + _destination = NULL; + } else { + _destination = FGAirport::findByIdent(aIdent); + } } diff --git a/src/Navaids/positioned.cxx b/src/Navaids/positioned.cxx index f3e683fb9..8130b54b9 100644 --- a/src/Navaids/positioned.cxx +++ b/src/Navaids/positioned.cxx @@ -694,6 +694,10 @@ FGPositioned::findClosestN(const SGGeod& aPos, unsigned int aN, double aCutoffNm FGPositionedRef FGPositioned::findNextWithPartialId(FGPositionedRef aCur, const std::string& aId, Filter* aFilter) { + if (aId.empty()) { + return NULL; + } + std::string id(boost::to_upper_copy(aId)); // It is essential to bound our search, to avoid iterating all the way to the end of the database.