Fix issue 10024: FP: nullPointerRedundantCheck when using a goto statement (#2947)
This commit is contained in:
parent
4d813a79ef
commit
da1375c9a3
|
@ -124,6 +124,8 @@ struct ReverseTraversal {
|
|||
}
|
||||
if (Token::Match(tok, "return|break|continue"))
|
||||
break;
|
||||
if (Token::Match(tok, "%name% :"))
|
||||
break;
|
||||
// Evaluate LHS of assignment before RHS
|
||||
if (Token* assignTok = assignExpr(tok)) {
|
||||
Token* assignTop = assignTok;
|
||||
|
|
|
@ -106,6 +106,7 @@ private:
|
|||
TEST_CASE(nullpointer63);
|
||||
TEST_CASE(nullpointer64);
|
||||
TEST_CASE(nullpointer65); // #9980
|
||||
TEST_CASE(nullpointer66); // #10024
|
||||
TEST_CASE(nullpointer_addressOf); // address of
|
||||
TEST_CASE(nullpointerSwitch); // #2626
|
||||
TEST_CASE(nullpointer_cast); // #4692
|
||||
|
@ -2032,6 +2033,23 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer66() {
|
||||
check("int f() {\n"
|
||||
" int ret = 0;\n"
|
||||
" int *v = nullptr;\n"
|
||||
" if (!MyAlloc(&v)) {\n"
|
||||
" ret = -1;\n"
|
||||
" goto done;\n"
|
||||
" }\n"
|
||||
" DoSomething(*v);\n"
|
||||
"done:\n"
|
||||
" if (v)\n"
|
||||
" MyFree(&v);\n"
|
||||
" return ret;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer_addressOf() { // address of
|
||||
check("void f() {\n"
|
||||
" struct X *x = 0;\n"
|
||||
|
|
Loading…
Reference in New Issue