diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index 426fd1bcd..aeb98fe86 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -165,7 +165,7 @@ namespace { , callbacks(callbacks) , mTrackExecution(trackExecution) , mDataIndex(trackExecution->getNewDataIndex()) {} - typedef std::map> Memory; + typedef std::map Memory; Memory memory; int * const symbolValueIndex; const Tokenizer * const tokenizer; @@ -198,6 +198,19 @@ namespace { structVal->member[memberName] = value; } + void functionCall() { + // Remove values for global variables + const SymbolDatabase *symbolDatabase = tokenizer->getSymbolDatabase(); + for (std::map::iterator it = memory.begin(); it != memory.end();) { + unsigned int varid = it->first; + const Variable *var = symbolDatabase->getVariableFromVarId(varid); + if (var->isGlobal()) + it = memory.erase(it); + else + ++it; + } + } + std::string getNewSymbolName() OVERRIDE { return "$" + std::to_string(++(*symbolValueIndex)); } @@ -1181,6 +1194,7 @@ static ExprEngine::ValuePtr executeFunctionCall(const Token *tok, Data &data) auto val = getValueRangeFromValueType(data.getNewSymbolName(), tok->valueType(), *data.settings); call(data.callbacks, tok, val, &data); + data.functionCall(); return val; }