CheckLeakAutoVar: Fixed FP seen in daca@home
This commit is contained in:
parent
a44ea9f2ed
commit
7a3302b3e3
|
@ -374,6 +374,9 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken,
|
|||
VarInfo::AllocInfo& varAlloc = alloctype[innerTok->varId()];
|
||||
varAlloc.type = f->groupId;
|
||||
varAlloc.status = VarInfo::ALLOC;
|
||||
} else {
|
||||
// Fixme: warn about leak
|
||||
alloctype.erase(innerTok->varId());
|
||||
}
|
||||
} else if (mTokenizer->isCPP() && Token::Match(innerTok->tokAt(2), "new !!(")) {
|
||||
const Token* tok2 = innerTok->tokAt(2)->astOperand1();
|
||||
|
|
|
@ -58,6 +58,8 @@ private:
|
|||
TEST_CASE(assign12); // #4236: FP. bar(&x);
|
||||
// TODO TEST_CASE(assign13); // #4237: FP. char*&ref=p; p=malloc(10); free(ref);
|
||||
TEST_CASE(assign14);
|
||||
TEST_CASE(assign15);
|
||||
TEST_CASE(assign16);
|
||||
|
||||
TEST_CASE(deallocuse1);
|
||||
TEST_CASE(deallocuse2);
|
||||
|
@ -311,6 +313,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void assign16() {
|
||||
check("void f() {\n"
|
||||
" char *p = malloc(10);\n"
|
||||
" free(p);\n"
|
||||
" if (p=dostuff()) *p = 0;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void deallocuse1() {
|
||||
check("void f(char *p) {\n"
|
||||
" free(p);\n"
|
||||
|
|
Loading…
Reference in New Issue