Null pointer: Fixed false positive discovered by Travis when self-checking cppcheck
This commit is contained in:
parent
189360ae20
commit
a6557f8c74
|
@ -735,7 +735,7 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
|
|||
nullPointerError(tok2, pointerName, vartok, inconclusive);
|
||||
else if (unknown)
|
||||
nullPointerError(tok2, pointerName, vartok, true);
|
||||
if (Token::Match(tok2, "%var% ?"))
|
||||
if (Token::Match(tok2, "%var% %oror%|&&|?"))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1726,6 +1726,12 @@ private:
|
|||
" return q ? p->x : 0;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (warning) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("int f(ABC *p) {\n" // FP : return &&
|
||||
" if (!p) {}\n"
|
||||
" return p && p->x;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// Test CheckNullPointer::nullConstantDereference
|
||||
|
@ -2215,8 +2221,8 @@ private:
|
|||
}
|
||||
|
||||
void functioncalllibrary() {
|
||||
Settings settings;
|
||||
Tokenizer tokenizer(&settings,this);
|
||||
Settings settings1;
|
||||
Tokenizer tokenizer(&settings1,this);
|
||||
std::istringstream code("void f() { int a,b; x(a,b); }");
|
||||
tokenizer.tokenize(code,"test.c");
|
||||
const Token *xtok = Token::findsimplematch(tokenizer.tokens(), "x");
|
||||
|
|
Loading…
Reference in New Issue