Fixed #7105 (False positive resourceLeak - socket handle wiped after close)

This commit is contained in:
Daniel Marjamäki 2017-07-07 21:51:48 +02:00
parent 101303a179
commit 6b48781fdc
2 changed files with 15 additions and 0 deletions

View File

@ -571,6 +571,9 @@ void CheckLeakAutoVar::functionCall(const Token *tok, VarInfo *varInfo, const Va
arg = arg->tokAt(5);
}
while (Token::Match(arg, "%var% . %var%"))
arg = arg->tokAt(2);
if (Token::Match(arg, "%var% [-,)] !!.") || Token::Match(arg, "& %var%")) {
// goto variable
if (arg->str() == "&")

View File

@ -76,6 +76,9 @@ private:
TEST_CASE(exit2);
TEST_CASE(exit3);
// handling function calls
TEST_CASE(functioncall1);
// goto
TEST_CASE(goto1);
TEST_CASE(goto2);
@ -894,6 +897,15 @@ private:
ASSERT_EQUALS("", errout.str());
}
void functioncall1() {
check("void f(struct S *p) {\n"
" p->x = malloc(10);\n"
" free(p->x);\n"
" p->x = 0;\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void goto1() {
check("static void f() {\n"
" int err = -ENOMEM;\n"