2018-02-22 08:20 EST


View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002173FSSCPPlatform-Engine interactionpublic2010-04-18 23:50
Reporteriss_mneur 
Assigned Toiss_mneur 
PrioritynormalSeveritycrashReproducibilityalways
StatusresolvedResolutionfixed 
Product Version3.6.12 RC1 
Target VersionFixed in Version3.6.12 
Summary0002173: FSO Fails with an assert if a commandline flag does not have an arg
DescriptionSince Taylor's revamping of the cmdline system to use dynamic buffers, if a command line flag is passed (either by proper command line or via cmdline_fso.cfg) that requires an argument int, float, or string, FSO fails with a very useless assertion message.

The attached patch makes the Error more useful and tells the user what they need to do to fix this, as well as it checks in release.

Because the Assertion is not in effect in release FSO could potentially try to dereference a NULL pointer as well.

TagsNo tags attached.
Attached Files
  • patch file icon pretty_missing_arg_errors.patch (1,682 bytes) 2010-03-31 18:35 -
    Index: code/cmdline/cmdline.cpp
    ===================================================================
    --- code/cmdline/cmdline.cpp	(revision 6045)
    +++ code/cmdline/cmdline.cpp	(working copy)
    @@ -50,6 +50,7 @@
     	int get_int();
     	float get_float();
     	char *str();
    +	bool check_if_args_is_valid();
     };
     
     static cmdline_parm Parm_list(NULL, NULL);
    @@ -800,7 +801,22 @@
     #endif
     }
     
    +// checks if the objects args variable is valid
    +// returns true if it is, shows an error box and returns false if not valid.
    +bool cmdline_parm::check_if_args_is_valid() {
    +	if ( args == NULL ) {
    +		Error(__FILE__, __LINE__, 
    +			"Command line flag passed that requires an argument, but the argument is missing!\r\n"
    +			"The flag is '%s', make sure that you have an argument that follows it.\r\n"
    +			"You may need to close your launcher and remove the flag manually from %s/data/cmdline_fso.cfg\r\n",
    +			name, "<Freespace directory>");
    +		return false;
    +	} else {
    +		return true;
    +	}
    +}
     
    +
     // returns - true if the parameter exists on the command line, otherwise false
     int cmdline_parm::found()
     {
    @@ -810,7 +826,8 @@
     // returns - the interger representation for the parameter arguement
     int cmdline_parm::get_int()
     {
    -	Assert(args);
    +	check_if_args_is_valid();
    +
     	int offset = 0;
     
     	if (stacks) {
    @@ -833,7 +850,8 @@
     // returns - the float representation for the parameter arguement
     float cmdline_parm::get_float()
     {
    -	Assert(args!=NULL);
    +	check_if_args_is_valid();
    +
     	int offset = 0;
     
     	if (stacks) {
    @@ -856,7 +874,8 @@
     // returns - the string value for the parameter arguement
     char *cmdline_parm::str()
     {
    -	Assert(args);
    +	check_if_args_is_valid();
    +
     	return args;
     }
     
    
    patch file icon pretty_missing_arg_errors.patch (1,682 bytes) 2010-03-31 18:35 +

-Relationships
+Relationships

-Notes

~0011849

iss_mneur (developer)

Note this affects both trunk and 3.6.12.

~0011892

Goober5000 (administrator)

Fix added in revision 6064.
+Notes

-Issue History
Date Modified Username Field Change
2010-03-31 18:35 iss_mneur New Issue
2010-03-31 18:35 iss_mneur File Added: pretty_missing_arg_errors.patch
2010-03-31 18:36 iss_mneur Note Added: 0011849
2010-04-18 23:50 Goober5000 Note Added: 0011892
2010-04-18 23:50 Goober5000 Assigned To => iss_mneur
2010-04-18 23:50 Goober5000 Status new => resolved
2010-04-18 23:50 Goober5000 Resolution open => fixed
2010-04-18 23:50 Goober5000 Fixed in Version => 3.6.12
+Issue History