Fixed #3942 (false positive: (error) Memory leak: keyword)

This commit is contained in:
Daniel Marjamäki 2012-08-21 17:02:11 +02:00
parent b4b5c80db9
commit 41b624230f
2 changed files with 11 additions and 0 deletions

View File

@ -506,6 +506,8 @@ void CheckLeakAutoVar::functionCall(const Token *tok, VarInfo *varInfo, const st
} else if (!dealloc.empty()) {
alloctype[arg->varId()] = "dealloc";
}
} else if (Token::Match(arg, "%var% (")) {
functionCall(arg, varInfo, dealloc);
}
}
}

View File

@ -43,6 +43,7 @@ private:
TEST_CASE(assign8);
TEST_CASE(assign9);
TEST_CASE(assign10);
TEST_CASE(assign11); // #3942: x = a(b(p));
TEST_CASE(deallocuse1);
TEST_CASE(deallocuse2);
@ -201,6 +202,14 @@ private:
ASSERT_EQUALS("", errout.str());
}
void assign11() { // #3942 - FP for x = a(b(p));
check("void f() {\n"
" char *p = malloc(10);\n"
" x = a(b(p));\n"
"}");
ASSERT_EQUALS("[test.c:4]: (information) b configuration is needed to establish if there is a leak or not\n", errout.str());
}
void deallocuse1() {
check("void f(char *p) {\n"
" free(p);\n"