Fixed #3942 (false positive: (error) Memory leak: keyword)
This commit is contained in:
parent
b4b5c80db9
commit
41b624230f
|
@ -506,6 +506,8 @@ void CheckLeakAutoVar::functionCall(const Token *tok, VarInfo *varInfo, const st
|
||||||
} else if (!dealloc.empty()) {
|
} else if (!dealloc.empty()) {
|
||||||
alloctype[arg->varId()] = "dealloc";
|
alloctype[arg->varId()] = "dealloc";
|
||||||
}
|
}
|
||||||
|
} else if (Token::Match(arg, "%var% (")) {
|
||||||
|
functionCall(arg, varInfo, dealloc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ private:
|
||||||
TEST_CASE(assign8);
|
TEST_CASE(assign8);
|
||||||
TEST_CASE(assign9);
|
TEST_CASE(assign9);
|
||||||
TEST_CASE(assign10);
|
TEST_CASE(assign10);
|
||||||
|
TEST_CASE(assign11); // #3942: x = a(b(p));
|
||||||
|
|
||||||
TEST_CASE(deallocuse1);
|
TEST_CASE(deallocuse1);
|
||||||
TEST_CASE(deallocuse2);
|
TEST_CASE(deallocuse2);
|
||||||
|
@ -201,6 +202,14 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void deallocuse1() {
|
||||||
check("void f(char *p) {\n"
|
check("void f(char *p) {\n"
|
||||||
" free(p);\n"
|
" free(p);\n"
|
||||||
|
|
Loading…
Reference in New Issue