Fixed #2493 (false positive: (error) Possible null pointer dereference: pExpr)
This commit is contained in:
parent
9d3b242cd8
commit
86e6822264
|
@ -608,7 +608,7 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
|
|||
}
|
||||
}
|
||||
|
||||
if (Token::Match(tok2, "goto|return|continue|break|throw|if"))
|
||||
if (Token::Match(tok2, "goto|return|continue|break|throw|if|switch"))
|
||||
{
|
||||
if (Token::Match(tok2, "return * %varid%", varid))
|
||||
nullPointerError(tok2, tok->strAt(3));
|
||||
|
|
|
@ -868,6 +868,19 @@ private:
|
|||
" fred->a();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #2493 - switch
|
||||
check("void f(Fred *fred) {\n"
|
||||
" if (fred == NULL) {\n"
|
||||
" x = 0;\n"
|
||||
" }\n"
|
||||
" switch (x) {\n"
|
||||
" case 1:\n"
|
||||
" fred->a();\n"
|
||||
" break;\n"
|
||||
" };\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// Test CheckNullPointer::nullConstantDereference
|
||||
|
|
Loading…
Reference in New Issue