Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jan 3, 2024
1 parent 3bd7a45 commit e0c1813
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/testleakautovar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ class TestLeakAutoVar : public TestFixture {
ASSERT_EQUALS("[test.c:4]: (error) Dereferencing 'p' after it is deallocated / released\n",
errout.str());

check("void g(int);\n"
check("int g(int);\n"
"void f(int* p) {\n"
" free(p);\n"
" g(*p);\n"
Expand All @@ -968,6 +968,19 @@ class TestLeakAutoVar : public TestFixture {
ASSERT_EQUALS("[test.c:4]: (error) Dereferencing 'p' after it is deallocated / released\n"
"[test.c:7] -> [test.c:8]: (error) Returning/dereferencing 'p' after it is deallocated / released\n",
errout.str());

check("int g(int, int);\n"
"void f(int* p) {\n"
" free(p);\n"
" g(0, 1 + *p);\n"
"}\n"
"int h(int* p) {\n"
" free(p);\n"
" return g(0, 1 + *p);\n"
"}\n");
ASSERT_EQUALS("[test.c:4]: (error) Dereferencing 'p' after it is deallocated / released\n"
"[test.c:7] -> [test.c:8]: (error) Returning/dereferencing 'p' after it is deallocated / released\n",
errout.str());
}

void doublefree1() { // #3895
Expand Down

0 comments on commit e0c1813

Please sign in to comment.