Regression test for 8742: False positive: ValueFlow regression (#3444)

This commit is contained in:
Paul Fultz II 2021-09-04 01:45:55 -05:00 committed by GitHub
parent b788e41191
commit 2b7523e466
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -120,6 +120,7 @@ private:
TEST_CASE(nullpointer78); // #7802
TEST_CASE(nullpointer79); // #10400
TEST_CASE(nullpointer80); // #10410
TEST_CASE(nullpointer81); // #8724
TEST_CASE(nullpointer_addressOf); // address of
TEST_CASE(nullpointerSwitch); // #2626
TEST_CASE(nullpointer_cast); // #4692
@ -2456,6 +2457,23 @@ private:
ASSERT_EQUALS("", errout.str());
}
void nullpointer81() // #8724
{
check("void f(A **list) {\n"
" A *tmp_List = NULL;\n"
" *list = NULL;\n"
" while (1) {\n"
" if (*list == NULL) {\n"
" tmp_List = malloc (sizeof (ArchiveList_struct));\n"
" *list = tmp_List;\n"
" } else {\n"
" tmp_List->next = malloc (sizeof (ArchiveList_struct));\n"
" }\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void nullpointer_addressOf() { // address of
check("void f() {\n"
" struct X *x = 0;\n"