diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index a0fe4049a..3cf8221a9 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2009 Daniel MarjamŠki and Cppcheck team. + * Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -340,7 +340,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vectorstrAt(2)); @@ -367,6 +367,10 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vectortokAt(2); } + else + { + continue; + } // Get index variable and stopsize. const char *strindex = strindextoken->str().c_str(); diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 8c9d7606b..dfd6e1917 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -332,8 +332,18 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); } - } + { + check("void foo(int argc)\n" + "{\n" + " char a[2];\n" + " for (int i = 4; i < argc; i++)\n" + " {\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + } void array_index_4() {