diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index a2bcd1db0..235684124 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -588,6 +588,8 @@ void CheckBufferOverrun::bufferOverflow() argtok = argtok->astOperand2(); if (!argtok || !argtok->variable()) continue; + if (argtok->valueType() && argtok->valueType()->pointer == 0) + continue; // TODO: strcpy(buf+10, "hello"); const ValueFlow::Value bufferSize = getBufferSize(argtok); if (bufferSize.intvalue <= 1) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index cbf61c1c0..8cc5ce60c 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -3388,6 +3388,11 @@ private: "}", settings); ASSERT_EQUALS("[test.cpp:3]: (error) Buffer is accessed out of bounds: c\n", errout.str()); + check("void f(unsigned int addr) {\n" + " memset((void *)addr, 0, 1000);\n" + "}", settings0); + ASSERT_EQUALS("", errout.str()); + check("struct AB { char a[10]; };\n" "void foo(AB *ab) {\n" " mystrncpy(x, ab->a, 100);\n"