Fix issue 9883: endless recursion in getLifetimeTokens (#2786)
This commit is contained in:
commit
18e99176e5
|
@ -3098,11 +3098,13 @@ std::vector<LifetimeToken> getLifetimeTokens(const Token* tok, bool escape, Valu
|
|||
for (const ValueFlow::Value &v : vartok->values()) {
|
||||
if (!v.isLocalLifetimeValue())
|
||||
continue;
|
||||
if (v.tokvalue == tok)
|
||||
continue;
|
||||
errorPath.insert(errorPath.end(), v.errorPath.begin(), v.errorPath.end());
|
||||
return getLifetimeTokens(v.tokvalue, escape, std::move(errorPath));
|
||||
return getLifetimeTokens(v.tokvalue, escape, std::move(errorPath), depth - 1);
|
||||
}
|
||||
} else {
|
||||
return LifetimeToken::setAddressOf(getLifetimeTokens(vartok, escape, std::move(errorPath)),
|
||||
return LifetimeToken::setAddressOf(getLifetimeTokens(vartok, escape, std::move(errorPath), depth - 1),
|
||||
!(astIsContainer(vartok) && Token::simpleMatch(vartok->astParent(), "[")));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4706,6 +4706,15 @@ private:
|
|||
"}\n";
|
||||
valueOfTok(code, "x");
|
||||
|
||||
code = "void f(){\n"
|
||||
" struct dwarf_data **pp;\n"
|
||||
" for (pp = (struct dwarf_data **) (void *) &state->fileline_data;\n"
|
||||
" *pp != NULL;\n"
|
||||
" pp = &(*pp)->next)\n"
|
||||
" ;\n"
|
||||
"}\n";
|
||||
valueOfTok(code, "x");
|
||||
|
||||
code = "void *foo(void *x);\n"
|
||||
"void *foo(void *x)\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue