Fix 10338: Hang/Crash in valueflow (#3328)
This commit is contained in:
parent
81eabb5f61
commit
3b9c399f72
|
@ -597,7 +597,7 @@ bool precedes(const Token * tok1, const Token * tok2)
|
||||||
if (!tok1)
|
if (!tok1)
|
||||||
return false;
|
return false;
|
||||||
if (!tok2)
|
if (!tok2)
|
||||||
return false;
|
return true;
|
||||||
return tok1->index() < tok2->index();
|
return tok1->index() < tok2->index();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -471,7 +471,7 @@ struct ForwardTraversal {
|
||||||
if (depth < 0)
|
if (depth < 0)
|
||||||
return Break(Analyzer::Terminate::Bail);
|
return Break(Analyzer::Terminate::Bail);
|
||||||
std::size_t i = 0;
|
std::size_t i = 0;
|
||||||
for (Token* tok = start; tok && tok != end; tok = tok->next()) {
|
for (Token* tok = start; precedes(tok, end); tok = tok->next()) {
|
||||||
Token* next = nullptr;
|
Token* next = nullptr;
|
||||||
if (tok->index() <= i)
|
if (tok->index() <= i)
|
||||||
throw InternalError(tok, "Cyclic forward analysis.");
|
throw InternalError(tok, "Cyclic forward analysis.");
|
||||||
|
|
|
@ -5630,6 +5630,15 @@ private:
|
||||||
" return e;\n"
|
" return e;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
valueOfTok(code, "x");
|
valueOfTok(code, "x");
|
||||||
|
|
||||||
|
code = "void a() {\n"
|
||||||
|
" int b = 0;\n"
|
||||||
|
" do {\n"
|
||||||
|
" for (;;)\n"
|
||||||
|
" break;\n"
|
||||||
|
" } while (b < 1);\n"
|
||||||
|
"}\n";
|
||||||
|
valueOfTok(code, "b");
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowCrashConstructorInitialization() { // #9577
|
void valueFlowCrashConstructorInitialization() { // #9577
|
||||||
|
|
Loading…
Reference in New Issue