Loops over all varIds should start at 1.

This commit is contained in:
PKEuS 2014-09-28 09:47:11 +02:00
parent ccd80e3407
commit 03b1afc28c
3 changed files with 4 additions and 4 deletions

View File

@ -1421,7 +1421,7 @@ void CheckClass::virtualDestructor()
// pointer variables of type 'Base *'
std::set<unsigned int> basepointer;
for (std::size_t k = 0; k < symbolDatabase->getVariableListSize(); k++) {
for (std::size_t k = 1; k < symbolDatabase->getVariableListSize(); k++) {
const Variable* var = symbolDatabase->getVariableFromVarId(k);
if (var && var->isPointer() && var->type() == derivedFrom)
basepointer.insert(var->declarationId());

View File

@ -2207,7 +2207,7 @@ void CheckMemoryLeakInFunction::check()
}
// Check variables..
for (unsigned int i = 0; i < symbolDatabase->getVariableListSize(); i++) {
for (unsigned int i = 1; i < symbolDatabase->getVariableListSize(); i++) {
const Variable* var = symbolDatabase->getVariableFromVarId(i);
if (!var || (!var->isLocal() && !var->isArgument()) || var->isStatic() || !var->scope())
continue;
@ -2449,7 +2449,7 @@ void CheckMemoryLeakInClass::publicAllocationError(const Token *tok, const std::
void CheckMemoryLeakStructMember::check()
{
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
for (unsigned int i = 0; i < symbolDatabase->getVariableListSize(); i++) {
for (unsigned int i = 1; i < symbolDatabase->getVariableListSize(); i++) {
const Variable* var = symbolDatabase->getVariableFromVarId(i);
if (!var || !var->isLocal() || var->isStatic())
continue;

View File

@ -2522,7 +2522,7 @@ void CheckOther::checkRedundantCopy()
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
for (std::size_t i = 0; i < symbolDatabase->getVariableListSize(); i++) {
for (std::size_t i = 1; i < symbolDatabase->getVariableListSize(); i++) {
const Variable* var = symbolDatabase->getVariableFromVarId(i);
if (!var || var->isReference() || !var->isConst() || var->isPointer() || (!var->type() && !var->isStlType())) // bailout if var is of standard type, if it is a pointer or non-const