Fix FP memleak (#4145)
This commit is contained in:
parent
d7c914bd3e
commit
423e67bd6a
|
@ -835,9 +835,13 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable * const var
|
||||||
if (getAllocationType(assignToks.second, assignToks.first->varId()) == AllocType::No)
|
if (getAllocationType(assignToks.second, assignToks.first->varId()) == AllocType::No)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (variable->isArgument() && variable->valueType() && variable->valueType()->type == ValueType::UNKNOWN_TYPE &&
|
if (variable->isArgument() && variable->valueType() && variable->valueType()->type == ValueType::UNKNOWN_TYPE && assignToks.first->astParent()) {
|
||||||
Token::simpleMatch(assignToks.first->astParent(), ".") && assignToks.first->astParent()->originalName() == "->")
|
const Token* accessTok = assignToks.first->astParent();
|
||||||
continue;
|
while (Token::simpleMatch(accessTok->astOperand1(), "."))
|
||||||
|
accessTok = accessTok->astOperand1();
|
||||||
|
if (Token::simpleMatch(accessTok, ".") && accessTok->originalName() == "->")
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const int structid(variable->declarationId());
|
const int structid(variable->declarationId());
|
||||||
const int structmemberid(assignToks.first->varId());
|
const int structmemberid(assignToks.first->varId());
|
||||||
|
|
|
@ -1949,6 +1949,8 @@ private:
|
||||||
|
|
||||||
check("void f(type_t t) {\n"
|
check("void f(type_t t) {\n"
|
||||||
" t->p = malloc(10);\n"
|
" t->p = malloc(10);\n"
|
||||||
|
" t->x.p = malloc(10);\n"
|
||||||
|
" t->y[2].p = malloc(10);\n"
|
||||||
"}\n", false);
|
"}\n", false);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue