Skip to content

Access violation when calling either of the Get/SetKeyValuesExpressionSymbol funcs multiple times #1918

@dillydylann

Description

@dillydylann

The new expression evaluator functions that were backported from L4D2 and Swarm crash when trying to get or set a global conditional.

Image

Here's some test code that sets the following conditionals and verifies them:

#include <vstdlib/IKeyValuesSystem.h>

KeyValuesSystem()->SetKeyValuesExpressionSymbol( "TEST1", true );
KeyValuesSystem()->SetKeyValuesExpressionSymbol( "TEST2", true ); // <-- Crashes here
KeyValuesSystem()->SetKeyValuesExpressionSymbol( "TEST3", false );
KeyValuesSystem()->SetKeyValuesExpressionSymbol( "TEST4", false );
Assert( KeyValuesSystem()->GetKeyValuesExpressionSymbol( "TEST1" ) );
Assert( KeyValuesSystem()->GetKeyValuesExpressionSymbol( "TEST2" ) );
Assert( !KeyValuesSystem()->GetKeyValuesExpressionSymbol( "TEST3" ) );
Assert( !KeyValuesSystem()->GetKeyValuesExpressionSymbol( "TEST4" ) );

And then uses the expression evaluator to determine if TEST1 is true and TEST3 is false:

#include <tier1/exprevaluator.h>

CExpressionEvaluator exprEval;
bool result;
exprEval.Evaluate( result, "$TEST1 && !$TEST3" ); // <-- Crashes when calling GetKeyValuesExpressionSymbol() inside this func
Assert( result );

Works fine in other branches. I'm also wondering why this was backported and not being used by KeyValues to replace the old EvaluateConditional function, like in other branches, or anywhere else in the SDK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions