Merge pull request #685 from Ragora/bugfix-color-key-by-name

BugFix: Correct data corruption potential in GuiInspectorField
This commit is contained in:
Brian Roberts 2021-11-24 21:38:10 -06:00 committed by GitHub
commit 13cd3de2ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -314,11 +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 );
newValue = (const char*)Con::evaluatef( "$f = \"%s\"; return ( %s );", oldValue.c_str(), buffer );
evaluationResult = Con::evaluatef("$f = \"%s\"; return ( %s );", oldValue.c_str(), buffer);
newValue = evaluationResult.getString();
Con::evaluatef("$f=0;");
}
else if( type == TypeS32Vector
@ -354,13 +356,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 );
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( newComponentVal );
strNew.append( evaluationResult.getString() );
isFirst = false;
}

View file

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