Merge pull request #2323 from Areloch/getFieldValueCrashfix

Sanity check for calling getFieldValue
This commit is contained in:
Areloch 2019-03-30 16:07:53 -05:00 committed by GitHub
commit 847618f4af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2834,13 +2834,16 @@ DefineEngineMethod( SimObject, getFieldValue, const char*, ( const char* fieldNa
"@param index Optional parameter to specify the index of an array field separately.\n"
"@return The value of the given field or \"\" if undefined." )
{
const U32 nameLen = dStrlen( fieldName );
if (nameLen == 0)
return "";
char fieldNameBuffer[ 1024 ];
char arrayIndexBuffer[ 64 ];
// Parse out index if the field is given in the form of 'name[index]'.
const char* arrayIndex = NULL;
const U32 nameLen = dStrlen( fieldName );
if( fieldName[ nameLen - 1 ] == ']' )
{
const char* leftBracket = dStrchr( fieldName, '[' );