parent
453800211c
commit
785c537ca2
|
@ -6306,6 +6306,34 @@ private:
|
||||||
" if ((b[0] = g()) == 0) {}\n"
|
" if ((b[0] = g()) == 0) {}\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
valueFlowUninit("void f(const char *x, char *y);\n" // #4527
|
||||||
|
"void g(char* b) {\n"
|
||||||
|
" char a[1000];\n"
|
||||||
|
" f(a, b);\n"
|
||||||
|
" printf(\"%s\", a);\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: a\n", errout.str());
|
||||||
|
|
||||||
|
valueFlowUninit("void usage(const char *);\n" // #10330
|
||||||
|
"int main(int argc, char* argv[]) {\n"
|
||||||
|
" int user = 0;\n"
|
||||||
|
" struct passwd* pwd;\n"
|
||||||
|
" while (1) {\n"
|
||||||
|
" int c = getc();\n"
|
||||||
|
" if (c == -1)\n"
|
||||||
|
" break;\n"
|
||||||
|
" switch (c) {\n"
|
||||||
|
" case 'u': user = 123; break;\n"
|
||||||
|
" }\n"
|
||||||
|
" }\n"
|
||||||
|
" if (argc == 1)\n"
|
||||||
|
" usage(argv[0]);\n"
|
||||||
|
" if (user)\n"
|
||||||
|
" pwd = getpwnam(user);\n"
|
||||||
|
" if (pwd == NULL) {}\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:15] -> [test.cpp:17]: (warning) Uninitialized variable: pwd\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value
|
void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value
|
||||||
|
|
Loading…
Reference in New Issue