From 4fca15fa1d215b47ee971cd487ca43d5ec0f3f37 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 25 Feb 2004 02:16:36 +0000 Subject: [PATCH] Avoid a possible segfault crash if a nonexistant airport is specified. --- src/Airports/runways.cxx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Airports/runways.cxx b/src/Airports/runways.cxx index 503f298f4..5c98af7ff 100644 --- a/src/Airports/runways.cxx +++ b/src/Airports/runways.cxx @@ -149,16 +149,21 @@ bool FGRunwayList::search( const string& aptid, FGRunway* r ) { bool FGRunwayList::search( const string& aptid, const string& rwyno, FGRunway *r ) { - // standardize input number + string revrwyno = ""; string runwayno = rwyno; - string tmp = runwayno.substr(1, 1); - if (( tmp == "L" || tmp == "R" || tmp == "C" ) || (runwayno.size() == 1)) { - tmp = runwayno; - runwayno = "0" + tmp; - SG_LOG( SG_GENERAL, SG_INFO, - "Standardising rwy number from " << tmp << " to " << runwayno ); + if ( runwayno.length() ) { + // standardize input number + string tmp = runwayno.substr(1, 1); + if (( tmp == "L" || tmp == "R" || tmp == "C" ) + || (runwayno.size() == 1)) + { + tmp = runwayno; + runwayno = "0" + tmp; + SG_LOG( SG_GENERAL, SG_INFO, "Standardising rwy number from " + << tmp << " to " << runwayno ); + } + revrwyno = GetReverseRunwayNo(runwayno); } - string revrwyno = GetReverseRunwayNo(runwayno); runway_map_iterator pos; for ( pos = runways.lower_bound( aptid );