parent
29e0133cb5
commit
b7693ccc7a
|
@ -533,8 +533,10 @@ bool CheckLeakAutoVar::checkScope(const Token * const startToken,
|
|||
return ChildrenToVisit::none;
|
||||
});
|
||||
|
||||
if (!checkScope(closingParenthesis->next(), &varInfo1, notzero, recursiveCount))
|
||||
if (!checkScope(closingParenthesis->next(), &varInfo1, notzero, recursiveCount)) {
|
||||
varInfo->clear();
|
||||
continue;
|
||||
}
|
||||
closingParenthesis = closingParenthesis->linkAt(1);
|
||||
if (Token::simpleMatch(closingParenthesis, "} else {")) {
|
||||
if (!checkScope(closingParenthesis->tokAt(2), &varInfo2, notzero, recursiveCount))
|
||||
|
|
|
@ -140,6 +140,7 @@ private:
|
|||
// goto
|
||||
TEST_CASE(goto1);
|
||||
TEST_CASE(goto2);
|
||||
TEST_CASE(goto3); // #11431
|
||||
|
||||
// if/else
|
||||
TEST_CASE(ifelse1);
|
||||
|
@ -1505,6 +1506,21 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void goto3() { // #11431
|
||||
check("void f() {\n"
|
||||
" int* p = (int*)malloc(2);\n"
|
||||
" if (!p) {\n"
|
||||
" p = (int*)malloc(1);\n"
|
||||
" if (!p)\n"
|
||||
" goto err;\n"
|
||||
" }\n"
|
||||
" free(p);\n"
|
||||
"err:\n"
|
||||
" (void)0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void ifelse1() {
|
||||
check("int f() {\n"
|
||||
" char *p = NULL;\n"
|
||||
|
|
Loading…
Reference in New Issue