Fixed 'possible null pointer dereference' warning messages
This commit is contained in:
parent
d2c0e5e7e6
commit
dc629b4c39
|
@ -811,6 +811,8 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
|||
// Check if the function deallocates the variable..
|
||||
while (ftok && (ftok->str() != "{"))
|
||||
ftok = ftok->next();
|
||||
if (!ftok)
|
||||
return 0;
|
||||
Token *func = getcode(ftok->tokAt(1), callstack, parameterVarid, alloctype, dealloctype, false, sz);
|
||||
//simplifycode(func, all);
|
||||
const Token *func_ = func;
|
||||
|
|
|
@ -876,6 +876,8 @@ void CheckOther::invalidFunctionUsage()
|
|||
const Token *tok2 = tok->tokAt(3);
|
||||
while (tok2 && tok2->str() != ",")
|
||||
tok2 = tok2->next();
|
||||
if (!tok2)
|
||||
continue;
|
||||
|
||||
// is any source buffer overlapping the target buffer?
|
||||
int parlevel = 0;
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
checkOther.checkComparisonOfBoolWithInt();
|
||||
checkOther.checkSwitchCaseFallThrough();
|
||||
checkOther.checkAlwaysTrueOrFalseStringCompare();
|
||||
|
||||
|
||||
checkOther.checkAssignBoolToPointer();
|
||||
}
|
||||
|
||||
|
|
|
@ -763,7 +763,8 @@ void CheckStl::if_find()
|
|||
while (decl && !Token::Match(decl, "[;{}(,]"))
|
||||
decl = decl->previous();
|
||||
|
||||
decl = decl->next();
|
||||
if (decl)
|
||||
decl = decl->next();
|
||||
|
||||
// stl container
|
||||
if (Token::Match(decl, "const| std :: %var% < %type% > &|*| %varid%", varid))
|
||||
|
@ -1137,8 +1138,10 @@ void CheckStl::checkAutoPointer()
|
|||
{
|
||||
tok3 = tok3->next();
|
||||
}
|
||||
if (!tok3)
|
||||
continue;
|
||||
tok3 = tok3->previous()->previous();
|
||||
if (Token::Match(tok3->previous(), "[ ] )"))
|
||||
if (Token::simpleMatch(tok3->previous(), "[ ] )"))
|
||||
{
|
||||
autoPointerArrayError(tok2->next());
|
||||
}
|
||||
|
|
|
@ -1088,7 +1088,7 @@ public:
|
|||
}
|
||||
|
||||
// found simple function..
|
||||
if (tok2->link() == tok->tokAt(2))
|
||||
if (tok2 && tok2->link() == tok->tokAt(2))
|
||||
func.insert(tok->next()->str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ private:
|
|||
void run()
|
||||
{
|
||||
TEST_CASE(assignBoolToPointer);
|
||||
|
||||
|
||||
TEST_CASE(zeroDiv1);
|
||||
TEST_CASE(zeroDiv2);
|
||||
TEST_CASE(zeroDiv3);
|
||||
|
|
Loading…
Reference in New Issue