From 08039f1fa5a76bf2afdabe15fda02a4179f204a2 Mon Sep 17 00:00:00 2001 From: jmt Date: Wed, 21 Oct 2009 07:18:36 +0000 Subject: [PATCH] Tweak permitted indices for GPS route insert commands. --- src/Instrumentation/gps.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 290dc6e4d..731e8f486 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -1290,7 +1290,7 @@ void GPS::setCommand(const char* aCmd) defineWaypoint(); } else if (!strcmp(aCmd, "route-insert-before")) { int index = _scratchNode->getIntValue("index"); - if (index < 0) { + if (index < 0 || (_routeMgr->size() == 0)) { index = _routeMgr->size(); } else if (index >= _routeMgr->size()) { SG_LOG(SG_INSTR, SG_WARN, "GPS:route-insert-before, bad index:" << index); @@ -1300,7 +1300,7 @@ void GPS::setCommand(const char* aCmd) insertWaypointAtIndex(index); } else if (!strcmp(aCmd, "route-insert-after")) { int index = _scratchNode->getIntValue("index"); - if (index < 0) { + if (index < 0 || (_routeMgr->size() == 0)) { index = _routeMgr->size(); } else if (index >= _routeMgr->size()) { SG_LOG(SG_INSTR, SG_WARN, "GPS:route-insert-after, bad index:" << index); -- 2.39.5