* [GuiInspectorField] BugFix: Correct data corruption potential caused by casting the result of Con::evaluatef directly to a const char.

This commit is contained in:
Robert MacGregor 2021-11-24 09:16:09 -05:00
parent 31c8d3ce3a
commit f1a48df676

View file

@ -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;
}