Fixed #2790 (Incorrect allocation mismatch error)
This commit is contained in:
parent
21a2a91b3c
commit
52499ca8f8
|
@ -1047,6 +1047,9 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
alloc = No;
|
||||
}
|
||||
}
|
||||
|
||||
if (alloc == No && alloctype == No)
|
||||
alloctype = CheckMemoryLeak::New;
|
||||
}
|
||||
|
||||
if (alloc != No)
|
||||
|
|
|
@ -208,6 +208,7 @@ private:
|
|||
TEST_CASE(mismatch2);
|
||||
TEST_CASE(mismatch3);
|
||||
TEST_CASE(mismatch4);
|
||||
TEST_CASE(mismatch5);
|
||||
|
||||
TEST_CASE(mismatchSize);
|
||||
|
||||
|
@ -1425,6 +1426,17 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:7]: (error) Mismatching allocation and deallocation: p\n", errout.str());
|
||||
}
|
||||
|
||||
void mismatch5()
|
||||
{
|
||||
check("void f() {\n"
|
||||
" C *c = new C;\n"
|
||||
" delete c;\n"
|
||||
" c = new C[2];\n"
|
||||
" delete [] c;\n"
|
||||
"}\n", false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void mismatchSize()
|
||||
{
|
||||
check("void f(char *buf)\n"
|
||||
|
|
Loading…
Reference in New Issue