Move declaration, run check earlier
This commit is contained in:
parent
67c9356455
commit
7c4b9bed9e
|
@ -890,9 +890,9 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
|
|||
}
|
||||
|
||||
// Writing data into array..
|
||||
if (Token::Match(tok, "strcpy|strcat ( %varid% , %str% )", declarationId)) {
|
||||
if (total_size > 0 && Token::Match(tok, "strcpy|strcat ( %varid% , %str% )", declarationId)) {
|
||||
const std::size_t len = Token::getStrLength(tok->tokAt(4));
|
||||
if (total_size > 0 && len >= (unsigned int)total_size) {
|
||||
if (len >= (unsigned int)total_size) {
|
||||
bufferOverrunError(tok, arrayInfo.varname());
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1092,8 +1092,6 @@ void CheckUnusedVar::checkFunctionVariableUsage()
|
|||
it != variables.varUsage().end();
|
||||
++it) {
|
||||
const Variables::VariableUsage &usage = it->second;
|
||||
const std::string &varname = usage._var->name();
|
||||
const Variable* var = symbolDatabase->getVariableFromVarId(it->first);
|
||||
|
||||
// variable has been marked as unused so ignore it
|
||||
if (usage._var->nameToken()->isAttributeUnused() || usage._var->nameToken()->isAttributeUsed())
|
||||
|
@ -1105,6 +1103,9 @@ void CheckUnusedVar::checkFunctionVariableUsage()
|
|||
usage._type == Variables::referenceArray)
|
||||
continue;
|
||||
|
||||
const std::string &varname = usage._var->name();
|
||||
const Variable* var = symbolDatabase->getVariableFromVarId(it->first);
|
||||
|
||||
// variable has had memory allocated for it, but hasn't done
|
||||
// anything with that memory other than, perhaps, freeing it
|
||||
if (usage.unused() && !usage._modified && usage._allocateMemory)
|
||||
|
|
Loading…
Reference in New Issue