]> git.mxchange.org Git - flightgear.git/commitdiff
Return an error when not enough tokens are parsed for the generic protocol, that...
authorehofman <ehofman>
Thu, 18 Jun 2009 11:20:02 +0000 (11:20 +0000)
committerTim Moore <timoore@redhat.com>
Tue, 23 Jun 2009 08:54:09 +0000 (10:54 +0200)
src/Main/fg_io.cxx

index a2260731e468ea44d712daa5a1a524a04dcaeaa4..2288fc538161d9d4f8c6802e364c2968633ae8dc 100644 (file)
@@ -102,6 +102,7 @@ FGIO::parse_port_config( const string& config )
        return 0;
     }
 
+    unsigned num_tokens = tokens.size();
     string protocol = tokens[0];
     SG_LOG( SG_IO, SG_INFO, "  protocol = " << protocol );
 
@@ -194,8 +195,16 @@ FGIO::parse_port_config( const string& config )
                 configToken = 5;
             else
                 configToken = 6;
-            FGGeneric *generic = new FGGeneric( tokens[configToken] );
-            io = generic;
+            if (configToken < num_tokens)
+            {
+               FGGeneric *generic = new FGGeneric( tokens[configToken] );
+               io = generic;
+            }
+            else
+            {
+               SG_LOG( SG_IO, SG_ALERT, "Not enough tokens passed for the generic protocol.");
+               return NULL;
+            }
        } else if ( protocol == "multiplay" ) {
            if ( tokens.size() != 5 ) {
                SG_LOG( SG_IO, SG_ALERT, "Ignoring invalid --multiplay option "