]> git.mxchange.org Git - flightgear.git/commitdiff
More sanity checks
authorfredb <fredb>
Tue, 21 Mar 2006 14:53:38 +0000 (14:53 +0000)
committerfredb <fredb>
Tue, 21 Mar 2006 14:53:38 +0000 (14:53 +0000)
src/Main/options.cxx

index 8a231927eff8c3a095d87424d168bb9ea4e2479f..b1c9d522b91a8713f27070c7452d582f7b752c08 100644 (file)
@@ -1419,7 +1419,7 @@ parse_option (const string& arg)
                     fgSetBool( pt->property, pt->b_param );
                     break;
                 case OPTION_STRING:
-                    if ( pt->has_param && pos != string::npos ) {
+                    if ( pt->has_param && pos != string::npos && pos + 1 < arg.size() ) {
                         fgSetString( pt->property, arg.substr( pos + 1 ).c_str() );
                     } else if ( !pt->has_param && pos == string::npos ) {
                         fgSetString( pt->property, pt->s_param );
@@ -1432,7 +1432,7 @@ parse_option (const string& arg)
                     }
                     break;
                 case OPTION_DOUBLE:
-                    if ( pos != string::npos ) {
+                    if ( pos != string::npos && pos + 1 < arg.size() ) {
                         fgSetDouble( pt->property, atof( arg.substr( pos + 1 ) ) );
                     } else {
                         SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
@@ -1440,7 +1440,7 @@ parse_option (const string& arg)
                     }
                     break;
                 case OPTION_INT:
-                    if ( pos != string::npos ) {
+                    if ( pos != string::npos && pos + 1 < arg.size() ) {
                         fgSetInt( pt->property, atoi( arg.substr( pos + 1 ) ) );
                     } else {
                         SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );