Skip to content

Commit 84885d5

Browse files
Update testmemleak.cpp
1 parent a74a1e7 commit 84885d5

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

test/testmemleak.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,7 @@ class TestMemleakStructMember : public TestFixture {
16741674
TEST_CASE(assign3);
16751675
TEST_CASE(assign4); // #11019
16761676
TEST_CASE(assign5);
1677+
TEST_CASE(assign6);
16771678

16781679
// Failed allocation
16791680
TEST_CASE(failedAllocation);
@@ -1955,6 +1956,15 @@ class TestMemleakStructMember : public TestFixture {
19551956
ASSERT_EQUALS("", errout_str());
19561957
}
19571958

1959+
void assign6() {
1960+
check("struct S { S* p; };\n" // #14524
1961+
"void f() {\n"
1962+
" S s;\n"
1963+
" s.p = static_cast<S*>(malloc(sizeof(S)));\n"
1964+
"}\n");
1965+
ASSERT_EQUALS("[test.cpp:5:1]: (error) Memory leak: s.p [memleak]\n", errout_str());
1966+
}
1967+
19581968
void failedAllocation() {
19591969
check("static struct ABC * foo()\n"
19601970
"{\n"

0 commit comments

Comments
 (0)