Fix FP deallocuse (#5183)
This commit is contained in:
parent
04476bc102
commit
55581fc2e9
|
@ -545,8 +545,10 @@ bool CheckLeakAutoVar::checkScope(const Token * const startToken,
|
|||
}
|
||||
closingParenthesis = closingParenthesis->linkAt(1);
|
||||
if (Token::simpleMatch(closingParenthesis, "} else {")) {
|
||||
if (!checkScope(closingParenthesis->tokAt(2), varInfo2, notzero, recursiveCount))
|
||||
continue;
|
||||
if (!checkScope(closingParenthesis->tokAt(2), varInfo2, notzero, recursiveCount)) {
|
||||
varInfo.clear();
|
||||
return false;
|
||||
}
|
||||
tok = closingParenthesis->linkAt(2)->previous();
|
||||
} else {
|
||||
tok = closingParenthesis->previous();
|
||||
|
|
|
@ -2080,6 +2080,22 @@ private:
|
|||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(node **p) {\n"
|
||||
" node* n = *p;\n"
|
||||
" if (n->left == NULL) {\n"
|
||||
" *p = n->right;\n"
|
||||
" free(n);\n"
|
||||
" }\n"
|
||||
" else if (n->right == NULL) {\n"
|
||||
" *p = n->left;\n"
|
||||
" free(n);\n"
|
||||
" }\n"
|
||||
" else {\n"
|
||||
" for (int i = 0; i < 4; ++i) {}\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void mismatchAllocDealloc() {
|
||||
|
|
Loading…
Reference in New Issue