diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 6ad4fff89..25be24834 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -1804,7 +1804,7 @@ bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &t _element_size = 0; _varname.clear(); - if (!tok->isName()) + if (!tok->isName() || tok->str() == "return") return false; while (tok && (tok->str() == "static" || diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 8d6c4c5f9..b052ef21c 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -180,6 +180,7 @@ private: TEST_CASE(executionPaths1); TEST_CASE(executionPaths2); + TEST_CASE(executionPaths3); // no FP for function parameter TEST_CASE(cmdLineArgs1); @@ -2514,6 +2515,20 @@ private: ASSERT_EQUALS("", errout.str()); } + void executionPaths3() + { + epcheck("void f(char *VLtext)\n" + "{\n" + " if ( x ) {\n" + " return VLtext[0];\n" + " } else {\n" + " int wordlen = ab();\n" + " VLtext[wordlen] = 0;\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void cmdLineArgs1() { check("int main(int argc, char* argv[])\n"