Pārlūkot izejas kodu

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

BugFix: Correct data corruption potential in GuiInspectorField
Brian Roberts 3 gadi atpakaļ
vecāks
revīzija
13cd3de2ad

+ 6 - 4
Engine/source/gui/editor/inspector/field.cpp

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

+ 2 - 1
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 );
    }