Refactorizations: Fixed a pattern in checkbufferoverrun.cpp, simplified one in checkclass.cpp
This commit is contained in:
parent
b2835051df
commit
18b0e14590
|
@ -663,7 +663,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector<std::str
|
|||
}
|
||||
} else if ((declarationId > 0 && Token::Match(tok, "strcpy|strcat ( %varid% , %var% )", declarationId)) ||
|
||||
(declarationId == 0 && Token::Match(tok, ("strcpy|strcat ( " + varnames + " , %var% )").c_str()))) {
|
||||
const Variable *var = tok->tokAt(4)->variable();
|
||||
const Variable *var = tok->tokAt(varcount + 4)->variable();
|
||||
if (var && var->isArray() && var->dimensions().size() == 1) {
|
||||
const std::size_t len = (std::size_t)var->dimension(0);
|
||||
if (len > (unsigned int)total_size) {
|
||||
|
|
|
@ -1348,10 +1348,8 @@ bool CheckClass::hasAllocation(const Function *func, const Scope* scope) const
|
|||
// Check for assignment to the deleted pointer (only if its a member of the class)
|
||||
if (var && isMemberVar(scope, var)) {
|
||||
for (const Token *tok1 = var->next(); tok1 && (tok1 != last); tok1 = tok1->next()) {
|
||||
if (Token::Match(tok1, "%var% =")) {
|
||||
if (tok1->str() == var->str())
|
||||
return true;
|
||||
}
|
||||
if (Token::Match(tok1, "%varid% =", var->varId()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue