Fix FP memleak with unknown ptr typedef (#4141)
* 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 * Fix FPs memleak with array and ptr to ptr * Fix FP memleak with unknown ptr typedef * Format
This commit is contained in:
parent
d5d6da0dd4
commit
16af6561c2
|
@ -835,6 +835,10 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable * const var
|
|||
if (getAllocationType(assignToks.second, assignToks.first->varId()) == AllocType::No)
|
||||
continue;
|
||||
|
||||
if (variable->isArgument() && variable->valueType() && variable->valueType()->type == ValueType::UNKNOWN_TYPE &&
|
||||
Token::simpleMatch(assignToks.first->astParent(), ".") && assignToks.first->astParent()->originalName() == "->")
|
||||
continue;
|
||||
|
||||
const int structid(variable->declarationId());
|
||||
const int structmemberid(assignToks.first->varId());
|
||||
|
||||
|
|
|
@ -1946,6 +1946,11 @@ private:
|
|||
" s->hdr = mmap(NULL, s->mpsz, PROT_READ, MAP_SHARED, fd, 0);\n"
|
||||
"}\n", false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(type_t t) {\n"
|
||||
" t->p = malloc(10);\n"
|
||||
"}\n", false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void failedAllocation() {
|
||||
|
|
Loading…
Reference in New Issue