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:
chrchr-github 2022-05-27 23:52:56 +02:00 committed by GitHub
parent d5d6da0dd4
commit 16af6561c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -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());

View File

@ -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() {