diff --git a/lib/programmemory.cpp b/lib/programmemory.cpp index 6cd0c55de30c..62012ec9e602 100644 --- a/lib/programmemory.cpp +++ b/lib/programmemory.cpp @@ -1327,7 +1327,8 @@ namespace { ValueFlow::Value executeMultiCondition(bool b, const Token* expr) { if (pm->hasValue(expr->exprId())) { - const ValueFlow::Value& v = pm->at(expr->exprId()); + const auto& pm2 = *pm; + const ValueFlow::Value& v = pm2.at(expr->exprId()); if (v.isIntValue()) return v; } @@ -1577,7 +1578,8 @@ namespace { return execute(expr->astOperand1()); } if (expr->exprId() > 0 && pm->hasValue(expr->exprId())) { - ValueFlow::Value result = pm->at(expr->exprId()); + const ProgramMemory& pm2 = *pm; + ValueFlow::Value result = pm2.at(expr->exprId()); if (result.isImpossible() && result.isIntValue() && result.intvalue == 0 && isUsedAsBool(expr, *settings)) { result.intvalue = !result.intvalue; result.setKnown(); @@ -1693,7 +1695,8 @@ namespace { if (!expr) return v; if (expr->exprId() > 0 && pm->hasValue(expr->exprId())) { - if (updateValue(v, pm->at(expr->exprId()))) + const auto& pm2 = *pm; + if (updateValue(v, pm2.at(expr->exprId()))) return v; } // Find symbolic values @@ -1704,7 +1707,8 @@ namespace { continue; if (value.tokvalue->exprId() > 0 && !pm->hasValue(value.tokvalue->exprId())) continue; - ValueFlow::Value v2 = pm->at(value.tokvalue->exprId()); + const auto& pm2 = *pm; + ValueFlow::Value v2 = pm2.at(value.tokvalue->exprId()); if (!v2.isIntValue() && value.intvalue != 0) continue; v2.intvalue += value.intvalue;