Adds a sanity check to SimObject's setFieldValue console method so if you pass in a blank field name it doesn't crash, instead asserting in debug, and logging the error in release

This commit is contained in:
Areloch 2024-04-19 00:00:37 -05:00
parent e5aa6e4a95
commit 51c1ab6b83

View file

@ -3073,6 +3073,13 @@ DefineEngineMethod( SimObject, setFieldValue, bool, ( const char* fieldName, con
char fieldNameBuffer[ 1024 ]; char fieldNameBuffer[ 1024 ];
char arrayIndexBuffer[ 64 ]; char arrayIndexBuffer[ 64 ];
if( !fieldName || !fieldName[0] )
{
AssertFatal(false, "SimObject::setFieldValue - Invalid field name.");
Con::errorf( "SimObject::setFieldValue - Invalid field name." );
return false;
}
// Parse out index if the field is given in the form of 'name[index]'. // Parse out index if the field is given in the form of 'name[index]'.
const char* arrayIndex = NULL; const char* arrayIndex = NULL;