Fix issue 9883: endless recursion in getLifetimeTokens
This commit is contained in:
parent
e802d85315
commit
d5489fd1f0
|
@ -3098,11 +3098,13 @@ std::vector<LifetimeToken> getLifetimeTokens(const Token* tok, bool escape, Valu
|
||||||
for (const ValueFlow::Value &v : vartok->values()) {
|
for (const ValueFlow::Value &v : vartok->values()) {
|
||||||
if (!v.isLocalLifetimeValue())
|
if (!v.isLocalLifetimeValue())
|
||||||
continue;
|
continue;
|
||||||
|
if (v.tokvalue == tok)
|
||||||
|
continue;
|
||||||
errorPath.insert(errorPath.end(), v.errorPath.begin(), v.errorPath.end());
|
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 {
|
} 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(), "[")));
|
!(astIsContainer(vartok) && Token::simpleMatch(vartok->astParent(), "[")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4706,6 +4706,15 @@ private:
|
||||||
"}\n";
|
"}\n";
|
||||||
valueOfTok(code, "x");
|
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"
|
code = "void *foo(void *x);\n"
|
||||||
"void *foo(void *x)\n"
|
"void *foo(void *x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue