diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 4cda0ce51..ecd7aac8c 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -992,7 +992,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector 0) { // No varid => function calls are not handled if (varid == 0) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index ba3cf9151..ecc3c7554 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -135,6 +135,7 @@ private: TEST_CASE(buffer_overrun_16); TEST_CASE(buffer_overrun_17); // ticket #2548 TEST_CASE(buffer_overrun_18); // ticket #2576 - for, calculation with loop variable + TEST_CASE(buffer_overrun_19); // #2597 - class member with unknown type TEST_CASE(buffer_overrun_bailoutIfSwitch); // ticket #2378 : bailoutIfSwitch // It is undefined behaviour to point out of bounds of an array @@ -1891,6 +1892,20 @@ private: errout.str()); } + void buffer_overrun_19() // #2597 - class member with unknown type + { + check("class A {\n" + "public:\n" + " u8 buf[10];\n" + " A();" + "};\n" + "\n" + "A::A() {\n" + " memset(buf, 0, 10);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void buffer_overrun_bailoutIfSwitch() { // No false positive