1
0
Fork 0

Return an error when not enough tokens are parsed for the generic protocol, that must be better than causing a segmentation fault.

This commit is contained in:
ehofman 2009-06-18 11:20:02 +00:00 committed by Tim Moore
parent b360d917ce
commit 879b4df9fc

View 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 "