Fix crash in valueFlowForLoopSimplifyAfter (#2573)
This commit is contained in:
parent
cdcde7855d
commit
f2527f5340
|
@ -4496,12 +4496,15 @@ static void valueFlowForLoopSimplifyAfter(Token *fortok, nonneg int varid, const
|
|||
else
|
||||
endToken = fortok->scope()->bodyEnd;
|
||||
|
||||
Token* blockTok = fortok->linkAt(1)->linkAt(1);
|
||||
std::list<ValueFlow::Value> values;
|
||||
values.emplace_back(num);
|
||||
values.back().errorPath.emplace_back(fortok,"After for loop, " + var->name() + " has value " + values.back().infoString());
|
||||
|
||||
valueFlowForwardVariable(
|
||||
fortok->linkAt(1)->linkAt(1)->next(), endToken, var, varid, values, false, false, tokenlist, errorLogger, settings);
|
||||
if (blockTok != endToken) {
|
||||
valueFlowForwardVariable(
|
||||
blockTok->next(), endToken, var, varid, values, false, false, tokenlist, errorLogger, settings);
|
||||
}
|
||||
}
|
||||
|
||||
static void valueFlowForLoop(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
||||
|
|
|
@ -4444,6 +4444,14 @@ private:
|
|||
" return r;\n"
|
||||
"}\n";
|
||||
valueOfTok(code, "0");
|
||||
|
||||
code = "void fa(int &colors) {\n"
|
||||
" for (int i = 0; i != 6; ++i) {}\n"
|
||||
"}\n"
|
||||
"void fb(not_null<int*> parent, int &&colors2) {\n"
|
||||
" dostuff(1);\n"
|
||||
"}\n";
|
||||
valueOfTok(code, "x");
|
||||
}
|
||||
|
||||
void valueFlowCrashConstructorInitialization() { // #9577
|
||||
|
|
Loading…
Reference in New Issue