diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 7a13b94bf..dbc41f16a 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -474,7 +474,7 @@ private: if (tok.varId()) { // array variable passed as function parameter.. if (Token::Match(tok.previous(), "[(,] %var% [+-,)]")) { - if (Token::Match(tok.previous(), "( %var% ) =")) + if (Token::Match(tok.previous(), "( %var% ) )| =")) ExecutionPath::bailOutVar(checks, tok.varId()); else use(checks, &tok); diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 60607beb4..768201db8 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -1132,6 +1132,13 @@ private: " printf(\"%s\", a);\n" "}"); ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n", errout.str()); + + checkUninitVar("void f() {\n" // Ticket #3497 + " char header[1];\n" + " *((unsigned char*)(header)) = 0xff;\n" + " return header[0];\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } // alloc..