Fixed #775 (###### If you see this, there is a bug ###### Token::Match() - varid was 0)

http://sourceforge.net/apps/trac/cppcheck/ticket/775
This commit is contained in:
Slava Semushin 2009-10-03 21:27:16 +07:00
parent 8dc9528a74
commit 9a48efec00
1 changed files with 11 additions and 11 deletions

View File

@ -252,18 +252,18 @@ void CheckBufferOverrun::checkScope(const Token *tok, const char *varname[], con
continue; continue;
int value = 0; int value = 0;
if (counter_varid) if (counter_varid == 0)
continue;
if (Token::Match(tok2, "%varid% < %num% ;", counter_varid))
{ {
if (Token::Match(tok2, "%varid% < %num% ;", counter_varid)) value = std::atoi(tok2->strAt(2));
{ max_counter_value = MathLib::toString<long>(value - 1);
value = std::atoi(tok2->strAt(2)); }
max_counter_value = MathLib::toString<long>(value - 1); else if (Token::Match(tok2, "%varid% <= %num% ;", counter_varid))
} {
else if (Token::Match(tok2, "%varid% <= %num% ;", counter_varid)) value = std::atoi(tok2->strAt(2)) + 1;
{ max_counter_value = tok2->strAt(2);
value = std::atoi(tok2->strAt(2)) + 1;
max_counter_value = tok2->strAt(2);
}
} }
// Get index variable and stopsize. // Get index variable and stopsize.