Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/testleakautovar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class TestLeakAutoVar : public TestFixture {
TEST_CASE(return10);
TEST_CASE(return11); // #13098
TEST_CASE(return12); // #12238
TEST_CASE(return13);

// General tests: variable type, allocation type, etc
TEST_CASE(test1);
Expand Down Expand Up @@ -2838,6 +2839,22 @@ class TestLeakAutoVar : public TestFixture {
ASSERT_EQUALS("", errout_str());
}

void return13() { // #4638
CheckOptions options;
options.cpp = true;
check("bool f() {\n"
" int* p = new int;\n"
" return p;\n"
"}\n"
"bool g() {\n"
" void* p = malloc(4);\n"
" return p;\n"
"}\n", options);
ASSERT_EQUALS("[test.cpp:3:5]: (error) Memory leak: p [memleak]\n"
"[test.cpp:7:5]: (error) Memory leak: p [memleak]\n",
errout_str());
}

void test1() {
check("void f(double*&p) {\n" // 3809
" p = malloc(0x100);\n"
Expand Down
Loading