File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6306,6 +6306,34 @@ class TestUninitVar : public TestFixture {
63066306 " if ((b[0] = g()) == 0) {}\n "
63076307 " }" );
63086308 ASSERT_EQUALS (" " , errout.str ());
6309+
6310+ valueFlowUninit (" void f(const char *x, char *y);\n " // #4527
6311+ " void g(char* b) {\n "
6312+ " char a[1000];\n "
6313+ " f(a, b);\n "
6314+ " printf(\" %s\" , a);\n "
6315+ " }" );
6316+ ASSERT_EQUALS (" [test.cpp:5]: (error) Uninitialized variable: a\n " , errout.str ());
6317+
6318+ valueFlowUninit (" void usage(const char *);\n " // #10330
6319+ " int main(int argc, char* argv[]) {\n "
6320+ " int user = 0;\n "
6321+ " struct passwd* pwd;\n "
6322+ " while (1) {\n "
6323+ " int c = getc();\n "
6324+ " if (c == -1)\n "
6325+ " break;\n "
6326+ " switch (c) {\n "
6327+ " case 'u': user = 123; break;\n "
6328+ " }\n "
6329+ " }\n "
6330+ " if (argc == 1)\n "
6331+ " usage(argv[0]);\n "
6332+ " if (user)\n "
6333+ " pwd = getpwnam(user);\n "
6334+ " if (pwd == NULL) {}\n "
6335+ " }" );
6336+ ASSERT_EQUALS (" [test.cpp:15] -> [test.cpp:17]: (warning) Uninitialized variable: pwd\n " , errout.str ());
63096337 }
63106338
63116339 void valueFlowUninitBreak () { // Do not show duplicate warnings about the same uninitialized value
You can’t perform that action at this time.
0 commit comments