From 6f418cc1832753669907641ccc1299a71a99aa76 Mon Sep 17 00:00:00 2001 From: Areloch Date: Sat, 23 Feb 2019 16:50:05 -0600 Subject: [PATCH 1/3] Sanity check so calling getFieldValue on a blank fieldName doesn't cause a crash. --- Engine/source/console/simObject.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Engine/source/console/simObject.cpp b/Engine/source/console/simObject.cpp index 447d96ce4..28cbf1007 100644 --- a/Engine/source/console/simObject.cpp +++ b/Engine/source/console/simObject.cpp @@ -2834,6 +2834,9 @@ 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." ) { + if (fieldName == "") + return ""; + char fieldNameBuffer[ 1024 ]; char arrayIndexBuffer[ 64 ]; From a4fde427b72f28b4bf07e064c8cfa508239fe85c Mon Sep 17 00:00:00 2001 From: Areloch Date: Sat, 23 Feb 2019 20:14:10 -0600 Subject: [PATCH 2/3] Update simObject.cpp better way to handle the validity check for const char* --- Engine/source/console/simObject.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Engine/source/console/simObject.cpp b/Engine/source/console/simObject.cpp index 28cbf1007..7374919f5 100644 --- a/Engine/source/console/simObject.cpp +++ b/Engine/source/console/simObject.cpp @@ -2834,7 +2834,8 @@ 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." ) { - if (fieldName == "") + const U32 nameLen = dStrlen( fieldName ); + if (nameLen == 0) return ""; char fieldNameBuffer[ 1024 ]; From cf21bf7dfd91ab445655e8d65af91b43eb17da85 Mon Sep 17 00:00:00 2001 From: Areloch Date: Sat, 23 Feb 2019 21:41:22 -0600 Subject: [PATCH 3/3] Update simObject.cpp Accidental redefine --- Engine/source/console/simObject.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Engine/source/console/simObject.cpp b/Engine/source/console/simObject.cpp index 7374919f5..6cf6fd029 100644 --- a/Engine/source/console/simObject.cpp +++ b/Engine/source/console/simObject.cpp @@ -2844,7 +2844,6 @@ DefineEngineMethod( SimObject, getFieldValue, const char*, ( const char* fieldNa // 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, '[' );