Fix FP memleak with array (#4133)
* Fix #11019 FN memleak with redundant pointer op * Style * Fix #7705 FN: Memory leak not detected on struct member * Fix FP memleak with function call, fix cppcheckError * Fix FP memleak with array
This commit is contained in:
parent
2b611709e2
commit
86763b7b0a
|
@ -795,7 +795,7 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable * const var
|
|||
return {};
|
||||
const Token* top = varTok;
|
||||
while (top->astParent()) {
|
||||
if (top->astParent()->str() == "(")
|
||||
if (Token::Match(top->astParent(), "(|["))
|
||||
return {};
|
||||
top = top->astParent();
|
||||
}
|
||||
|
|
|
@ -1922,6 +1922,14 @@ private:
|
|||
" sess->fp = popen(cmd, rcmd == RSH_PIPE_READ ? \"r\" : \"w\");\n"
|
||||
"}\n", false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct S { char* a[2]; };\n"
|
||||
"enum E { E0, E1 };\n"
|
||||
"void f(struct S* s, enum E e, const char* n) {\n"
|
||||
" free(s->a[e]);\n"
|
||||
" s->a[e] = strdup(n);\n"
|
||||
"}\n", false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void failedAllocation() {
|
||||
|
|
Loading…
Reference in New Issue