Skip to content

Commit 474fed4

Browse files
committed
memleak: Fixed false negative for sample
1 parent b2e66a2 commit 474fed4

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

lib/checkleakautovar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ const Token * CheckLeakAutoVar::checkTokenInsideExpression(const Token * const t
735735
deallocUseError(tok, tok->str());
736736
} else if (Token::simpleMatch(tok->tokAt(-2), "= &")) {
737737
varInfo->erase(tok->varId());
738-
} else if (tok->strAt(-1) == "=") {
738+
} else if (Token::Match(tok->previous(), "= %var% [;,)]")) {
739739
varInfo->erase(tok->varId());
740740
}
741741
} else if (Token::Match(tok->previous(), "& %name% = %var% ;")) {

samples/memleak/out.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
samples/memleak/bad.c:8:5: error: Memory leak: a [memleak]
2+
return result;
3+
^

0 commit comments

Comments
 (0)