Add regression test for 9573: ValueFlow: Wrong tracking of value in function call (#2603)

This commit is contained in:
Paul Fultz II 2020-04-15 01:09:36 -05:00 committed by GitHub
parent 3be79aee98
commit 985c82730e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -94,6 +94,7 @@ private:
TEST_CASE(nullpointer51);
TEST_CASE(nullpointer52);
TEST_CASE(nullpointer53); // #8005
TEST_CASE(nullpointer54); // #9573
TEST_CASE(nullpointer_addressOf); // address of
TEST_CASE(nullpointerSwitch); // #2626
TEST_CASE(nullpointer_cast); // #4692
@ -1762,6 +1763,22 @@ private:
ASSERT_EQUALS("[test.cpp:3]: (warning) Possible null pointer dereference: params\n", errout.str());
}
void nullpointer54() {
check("int foo (int **array, size_t n_array) {\n"
" size_t i;\n"
" for (i = 0; i < n_array; ++i) {\n"
" if (*array[i] == 1)\n"
" return 1;\n"
" }\n"
" return 0;\n"
"} \n"
"int bar() {\n"
" int **array = NULL; \n"
" foo (array, 0);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void nullpointer_addressOf() { // address of
check("void f() {\n"
" struct X *x = 0;\n"