diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 8eac976fb..74fe596a0 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -897,9 +897,14 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector= arrayInfo.num(i)) { + if (indexes.size() == 1U) { + arrayIndexOutOfBoundsError(tok->tokAt(1 + varc), arrayInfo, indexes); + break; // only warn about the first one + } + // The access is still within the memory range for the array // so it may be intentional. - if (_settings->inconclusive) { + else if (_settings->inconclusive) { arrayIndexOutOfBoundsError(tok->tokAt(1 + varc), arrayInfo, indexes); break; // only warn about the first one }