From eebb1671a53b6861b45bfecefc7b5ec30586e07c Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Sun, 9 Aug 2009 01:09:45 +0700 Subject: [PATCH] checkbufferoverrun.cpp: get rid of Match() usage with varid 0. --- src/checkbufferoverrun.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/checkbufferoverrun.cpp b/src/checkbufferoverrun.cpp index 8c5d789ad..946c79cfe 100644 --- a/src/checkbufferoverrun.cpp +++ b/src/checkbufferoverrun.cpp @@ -248,13 +248,16 @@ void CheckBufferOverrun::checkScope(const Token *tok, const char *varname[], con else continue; - if (Token::Match(tok2, "%varid% < %num% ;", counter_varid)) + if (counter_varid) { - max_counter_value = MathLib::toString(atol(tok2->strAt(2)) - 1); - } - else if (Token::Match(tok2, "%varid% <= %num% ;", counter_varid)) - { - max_counter_value = tok2->strAt(2); + if (Token::Match(tok2, "%varid% < %num% ;", counter_varid)) + { + max_counter_value = MathLib::toString(atol(tok2->strAt(2)) - 1); + } + else if (Token::Match(tok2, "%varid% <= %num% ;", counter_varid)) + { + max_counter_value = tok2->strAt(2); + } } // Get index variable and stopsize.