From f1a48df6763dc61c962d1fcf26d3d5abb8266622 Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Wed, 24 Nov 2021 09:16:09 -0500 Subject: [PATCH 1/3] * [GuiInspectorField] BugFix: Correct data corruption potential caused by casting the result of Con::evaluatef directly to a const char. --- Engine/source/gui/editor/inspector/field.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Engine/source/gui/editor/inspector/field.cpp b/Engine/source/gui/editor/inspector/field.cpp index 6ee578512..75d219730 100644 --- a/Engine/source/gui/editor/inspector/field.cpp +++ b/Engine/source/gui/editor/inspector/field.cpp @@ -318,7 +318,8 @@ void GuiInspectorField::setData( const char* data, bool callbacks ) { char buffer[ 2048 ]; expandEscape( buffer, newValue ); - newValue = (const char*)Con::evaluatef( "$f = \"%s\"; return ( %s );", oldValue.c_str(), buffer ); + ConsoleValue result = Con::evaluatef("$f = \"%s\"; return ( %s );", oldValue.c_str(), buffer); + newValue = result.getString(); Con::evaluatef("$f=0;"); } else if( type == TypeS32Vector @@ -354,13 +355,13 @@ void GuiInspectorField::setData( const char* data, bool callbacks ) char buffer[ 2048 ]; expandEscape( buffer, newComponentExpr ); - const char* newComponentVal = Con::evaluatef( "$f = \"%s\"; $v = \"%s\"; return ( %s );", - oldComponentVal, oldValue.c_str(), buffer ); + ConsoleValue result = Con::evaluatef("$f = \"%s\"; $v = \"%s\"; return ( %s );", + oldComponentVal, oldValue.c_str(), buffer); Con::evaluatef("$f=0;$v=0;"); if( !isFirst ) strNew.append( ' ' ); - strNew.append( newComponentVal ); + strNew.append( result.getString() ); isFirst = false; } From 4dea3810b99f2ff48b5f1204a0560a0567f6b530 Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Wed, 24 Nov 2021 13:46:18 -0500 Subject: [PATCH 2/3] * [SFXDescription] BugFix: Correct a data corruption issue in converting legacy channel values. --- Engine/source/sfx/sfxDescription.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Engine/source/sfx/sfxDescription.cpp b/Engine/source/sfx/sfxDescription.cpp index 143e0a31e..8cd93b6b2 100644 --- a/Engine/source/sfx/sfxDescription.cpp +++ b/Engine/source/sfx/sfxDescription.cpp @@ -454,7 +454,8 @@ bool SFXDescription::onAdd() const char* channelValue = getDataField( sChannel, NULL ); if( channelValue && channelValue[ 0 ] ) { - const char* group = Con::evaluatef( "return sfxOldChannelToGroup( %s );", channelValue ); + ConsoleValue result = Con::evaluatef( "return sfxOldChannelToGroup( %s );", channelValue ); + const char* group = result.getString(); if( !Sim::findObject( group, mSourceGroup ) ) Con::errorf( "SFXDescription::onAdd - could not resolve channel '%s' to SFXSource", channelValue ); } From 41e5988c4608cb3d957709ce9a606d2387d803aa Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Wed, 24 Nov 2021 14:14:24 -0500 Subject: [PATCH 3/3] * BugFix: Correct a scoping error with ConsoleValue in the updated code in GuiInspectorField. --- Engine/source/gui/editor/inspector/field.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Engine/source/gui/editor/inspector/field.cpp b/Engine/source/gui/editor/inspector/field.cpp index 75d219730..752ba61d2 100644 --- a/Engine/source/gui/editor/inspector/field.cpp +++ b/Engine/source/gui/editor/inspector/field.cpp @@ -314,12 +314,13 @@ void GuiInspectorField::setData( const char* data, bool callbacks ) String newValue = strData; S32 type= mField->type; + ConsoleValue evaluationResult; if( type == TypeS8 || type == TypeS32 || type == TypeF32 ) { char buffer[ 2048 ]; expandEscape( buffer, newValue ); - ConsoleValue result = Con::evaluatef("$f = \"%s\"; return ( %s );", oldValue.c_str(), buffer); - newValue = result.getString(); + evaluationResult = Con::evaluatef("$f = \"%s\"; return ( %s );", oldValue.c_str(), buffer); + newValue = evaluationResult.getString(); Con::evaluatef("$f=0;"); } else if( type == TypeS32Vector @@ -355,13 +356,13 @@ void GuiInspectorField::setData( const char* data, bool callbacks ) char buffer[ 2048 ]; expandEscape( buffer, newComponentExpr ); - ConsoleValue result = Con::evaluatef("$f = \"%s\"; $v = \"%s\"; return ( %s );", + evaluationResult = Con::evaluatef("$f = \"%s\"; $v = \"%s\"; return ( %s );", oldComponentVal, oldValue.c_str(), buffer); Con::evaluatef("$f=0;$v=0;"); if( !isFirst ) strNew.append( ' ' ); - strNew.append( result.getString() ); + strNew.append( evaluationResult.getString() ); isFirst = false; }