Skip to content

Commit 41bdd87

Browse files
Fix #11875: hang in hasBorrowingVariables() (#5337)
1 parent 74c4daa commit 41bdd87

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

lib/valueflow.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4259,10 +4259,9 @@ struct LifetimeStore {
42594259
static bool hasBorrowingVariables(const std::list<Variable>& vars, const std::vector<const Token*>& args, int depth = 10)
42604260
{
42614261
if (depth < 0)
4262-
return false;
4262+
return true;
42634263
return std::any_of(vars.cbegin(), vars.cend(), [&](const Variable& var) {
4264-
const ValueType* vt = var.valueType();
4265-
if (vt) {
4264+
if (const ValueType* vt = var.valueType()) {
42664265
if (vt->pointer > 0 &&
42674266
std::none_of(args.begin(), args.end(), [vt](const Token* arg) {
42684267
return arg->valueType() && arg->valueType()->type == vt->type;

test/testvalueflow.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7359,6 +7359,17 @@ class TestValueFlow : public TestFixture {
73597359
" if (llabs(0x80000000ffffffffL) == 0x7fffffff00000001L) {}\n"
73607360
"}\n";
73617361
valueOfTok(code, "f");
7362+
7363+
code = "struct T {\n"
7364+
" T();\n"
7365+
" static T a[6][64];\n"
7366+
" static T b[2][64];\n"
7367+
" static T c[64][64];\n"
7368+
" static T d[2][64];\n"
7369+
" static T e[64];\n"
7370+
" static T f[64];\n"
7371+
"};\n";
7372+
valueOfTok(code, "(");
73627373
}
73637374

73647375
void valueFlowCrashConstructorInitialization() { // #9577

0 commit comments

Comments
 (0)