From ea23033a65150840fdd88df85e776599ccc94650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 11 Mar 2019 20:33:08 +0100 Subject: [PATCH] Array index out of bounds: Fix false positive --- lib/checkbufferoverrun.cpp | 2 +- test/testbufferoverrun.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 1760c410c..8ba87b2c3 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -192,7 +192,7 @@ void CheckBufferOverrun::arrayIndex() const Token *stringLiteral = nullptr; - if (tok->variable()->dimensions().empty()) { + if (!tok->variable()->isArray() && tok->variable()->dimensions().empty()) { stringLiteral = tok->getValueTokenMinStrSize(); if (!stringLiteral) continue; diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 32deb0275..446700138 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -3324,7 +3324,7 @@ private: " char c[10] = \"c\";\n" " mymemset(c, 0, 10);\n" "}", settings); - // TODO ASSERT_EQUALS("", errout.str()); + ASSERT_EQUALS("", errout.str()); } void minsize_sizeof() {