Skip to content

Commit 7f0a646

Browse files
Update checkmemoryleak.cpp
1 parent cb76e52 commit 7f0a646

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lib/checkmemoryleak.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,8 +858,15 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable* const vari
858858
// This struct member is allocated.. check that it is deallocated
859859
int indentlevel3 = indentlevel2;
860860
for (const Token *tok3 = tok2; tok3; tok3 = tok3->next()) {
861-
if (tok3->str() == "{")
862-
++indentlevel3;
861+
if (tok3->str() == "{") {
862+
if (tok3->scope()->type == ScopeType::eIf) { // bailout: member checked in if condition
863+
const Token* const condBeg = tok3->scope()->classDef->tokAt(1);
864+
const Token* const condEnd = condBeg->link();
865+
if (Token::findmatch(condBeg, ". %varid%", condEnd, assignToks.first->varId()))
866+
break;
867+
}
868+
++identlevel3;
869+
}
863870

864871
else if (tok3->str() == "}") {
865872
if (indentlevel3 == 0) {

0 commit comments

Comments
 (0)