Fixed #3866 (false positive: memory leak (UNLIKELY))
This commit is contained in:
parent
2481b80875
commit
62f92fe253
|
@ -302,8 +302,11 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken,
|
|||
varInfo2.erase(tok->tokAt(2)->varId());
|
||||
if (notzero.find(tok->tokAt(2)->varId()) != notzero.end())
|
||||
varInfo2.clear();
|
||||
} else if (Token::Match(tok->next(), "( ! %var% )|&&"))
|
||||
} else if (Token::Match(tok->next(), "( ! %var% )|&&")) {
|
||||
varInfo1.erase(tok->tokAt(3)->varId());
|
||||
} else if (Token::Match(tok->next(), "( %var% ( ! %var% ) )|&&")) {
|
||||
varInfo1.erase(tok->tokAt(5)->varId());
|
||||
}
|
||||
|
||||
checkScope(tok2->next(), &varInfo1, notzero);
|
||||
tok2 = tok2->linkAt(1);
|
||||
|
|
|
@ -299,6 +299,14 @@ private:
|
|||
" free(p);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #3866 - UNLIKELY
|
||||
check("void f() {\n"
|
||||
" char *p = malloc(10);\n"
|
||||
" if (UNLIKELY(!p)) { return; }\n"
|
||||
" free(p);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void ifelse4() {
|
||||
|
|
Loading…
Reference in New Issue