Fixed #4314: Using CheckNullPointer::isPointerDeRef() here is overkill and doesn't work as intended, since this function is designed to return 'false' if it isn't sure.
This commit is contained in:
parent
c9e0089546
commit
a36e008967
|
@ -19,7 +19,6 @@
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
#include "checkother.h"
|
||||
#include "checknullpointer.h" // CheckNullPointer::isPointerDeRef()
|
||||
#include "mathlib.h"
|
||||
#include "symboldatabase.h"
|
||||
|
||||
|
@ -3109,9 +3108,8 @@ void CheckOther::checkSuspiciousStringCompare()
|
|||
|
||||
const Variable* var = symbolDatabase->getVariableFromVarId(varTok->varId());
|
||||
if (var) {
|
||||
bool unknown=false;
|
||||
if (_tokenizer->isC() ||
|
||||
(var->isPointer() && !CheckNullPointer::isPointerDeRef(tok, unknown, symbolDatabase)))
|
||||
(var->isPointer() && varTok->strAt(-1) != "*" && !Token::Match(varTok->next(), "[.([]")))
|
||||
suspiciousStringCompareError(tok, var->name());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5181,6 +5181,11 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("bool foo(const Foo* c) {\n"
|
||||
" return \"x\" == c->bar();\n" // #4314
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Ticket #4257
|
||||
check("bool foo() {\n"
|
||||
"MyString *str=Getter();\n"
|
||||
|
|
Loading…
Reference in New Issue