This commit is contained in:
parent
1e2863cd33
commit
e106654993
|
@ -181,7 +181,10 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getReallocationType(const Token *tok
|
||||||
const Library::AllocFunc *f = mSettings_->library.getReallocFuncInfo(tok2);
|
const Library::AllocFunc *f = mSettings_->library.getReallocFuncInfo(tok2);
|
||||||
if (!(f && f->reallocArg > 0 && f->reallocArg <= numberOfArguments(tok2)))
|
if (!(f && f->reallocArg > 0 && f->reallocArg <= numberOfArguments(tok2)))
|
||||||
return No;
|
return No;
|
||||||
const Token* arg = getArguments(tok2).at(f->reallocArg - 1);
|
const auto args = getArguments(tok2);
|
||||||
|
if (args.size() < (f->reallocArg))
|
||||||
|
return No;
|
||||||
|
const Token* arg = args.at(f->reallocArg - 1);
|
||||||
while (arg && arg->isCast())
|
while (arg && arg->isCast())
|
||||||
arg = arg->astOperand1();
|
arg = arg->astOperand1();
|
||||||
while (arg && arg->isUnaryOp("*"))
|
while (arg && arg->isUnaryOp("*"))
|
||||||
|
|
|
@ -2177,6 +2177,8 @@ private:
|
||||||
|
|
||||||
// Test getAllocationType for subfunction
|
// Test getAllocationType for subfunction
|
||||||
TEST_CASE(getAllocationType);
|
TEST_CASE(getAllocationType);
|
||||||
|
|
||||||
|
TEST_CASE(crash1); // #10729
|
||||||
}
|
}
|
||||||
|
|
||||||
void functionParameter() {
|
void functionParameter() {
|
||||||
|
@ -2565,6 +2567,18 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void crash1() { // #10729
|
||||||
|
check("void foo() {\n"
|
||||||
|
" extern void *realloc (void *ptr, size_t size);\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void foo() {\n"
|
||||||
|
" extern void *malloc (size_t size);\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
REGISTER_TEST(TestMemleakNoVar)
|
REGISTER_TEST(TestMemleakNoVar)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue