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)) ||
|
} else if ((declarationId > 0 && Token::Match(tok, "strcpy|strcat ( %varid% , %var% )", declarationId)) ||
|
||||||
(declarationId == 0 && Token::Match(tok, ("strcpy|strcat ( " + varnames + " , %var% )").c_str()))) {
|
(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) {
|
if (var && var->isArray() && var->dimensions().size() == 1) {
|
||||||
const std::size_t len = (std::size_t)var->dimension(0);
|
const std::size_t len = (std::size_t)var->dimension(0);
|
||||||
if (len > (unsigned int)total_size) {
|
if (len > (unsigned int)total_size) {
|
||||||
|
|
|
@ -1348,13 +1348,11 @@ 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)
|
// Check for assignment to the deleted pointer (only if its a member of the class)
|
||||||
if (var && isMemberVar(scope, var)) {
|
if (var && isMemberVar(scope, var)) {
|
||||||
for (const Token *tok1 = var->next(); tok1 && (tok1 != last); tok1 = tok1->next()) {
|
for (const Token *tok1 = var->next(); tok1 && (tok1 != last); tok1 = tok1->next()) {
|
||||||
if (Token::Match(tok1, "%var% =")) {
|
if (Token::Match(tok1, "%varid% =", var->varId()))
|
||||||
if (tok1->str() == var->str())
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue