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
|
else
|
||||||
endToken = fortok->scope()->bodyEnd;
|
endToken = fortok->scope()->bodyEnd;
|
||||||
|
|
||||||
|
Token* blockTok = fortok->linkAt(1)->linkAt(1);
|
||||||
std::list<ValueFlow::Value> values;
|
std::list<ValueFlow::Value> values;
|
||||||
values.emplace_back(num);
|
values.emplace_back(num);
|
||||||
values.back().errorPath.emplace_back(fortok,"After for loop, " + var->name() + " has value " + values.back().infoString());
|
values.back().errorPath.emplace_back(fortok,"After for loop, " + var->name() + " has value " + values.back().infoString());
|
||||||
|
|
||||||
|
if (blockTok != endToken) {
|
||||||
valueFlowForwardVariable(
|
valueFlowForwardVariable(
|
||||||
fortok->linkAt(1)->linkAt(1)->next(), endToken, var, varid, values, false, false, tokenlist, errorLogger, settings);
|
blockTok->next(), endToken, var, varid, values, false, false, tokenlist, errorLogger, settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void valueFlowForLoop(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
static void valueFlowForLoop(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
||||||
|
|
|
@ -4444,6 +4444,14 @@ private:
|
||||||
" return r;\n"
|
" return r;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
valueOfTok(code, "0");
|
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
|
void valueFlowCrashConstructorInitialization() { // #9577
|
||||||
|
|
Loading…
Reference in New Issue