Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #11875: hang in hasBorrowingVariables() #5337

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4259,10 +4259,9 @@ struct LifetimeStore {
static bool hasBorrowingVariables(const std::list<Variable>& vars, const std::vector<const Token*>& args, int depth = 10)
{
if (depth < 0)
return false;
return true;
return std::any_of(vars.cbegin(), vars.cend(), [&](const Variable& var) {
const ValueType* vt = var.valueType();
if (vt) {
if (const ValueType* vt = var.valueType()) {
if (vt->pointer > 0 &&
std::none_of(args.begin(), args.end(), [vt](const Token* arg) {
return arg->valueType() && arg->valueType()->type == vt->type;
Expand Down
11 changes: 11 additions & 0 deletions test/testvalueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7359,6 +7359,17 @@ class TestValueFlow : public TestFixture {
" if (llabs(0x80000000ffffffffL) == 0x7fffffff00000001L) {}\n"
"}\n";
valueOfTok(code, "f");

code = "struct T {\n"
" T();\n"
" static T a[6][64];\n"
" static T b[2][64];\n"
" static T c[64][64];\n"
" static T d[2][64];\n"
" static T e[64];\n"
" static T f[64];\n"
"};\n";
valueOfTok(code, "(");
}

void valueFlowCrashConstructorInitialization() { // #9577
Expand Down
Loading