From 34082bc1fc6ef617ab4e24edbfee7456c2122a49 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 22 Mar 2020 15:01:13 +0000 Subject: [PATCH] MFC r357835: fusefs: fix some memory leaks in the tests. Oddly, most of these were not detected by Coverity. Reported by: Coverity (one of them, anyway) Coverity CID: 1404490 --- tests/sys/fs/fusefs/read.cc | 3 +++ tests/sys/fs/fusefs/write.cc | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/tests/sys/fs/fusefs/read.cc b/tests/sys/fs/fusefs/read.cc index a333b9f15a3..22a26c2701f 100644 --- a/tests/sys/fs/fusefs/read.cc +++ b/tests/sys/fs/fusefs/read.cc @@ -778,6 +778,7 @@ TEST_F(Read, cache_block) ASSERT_EQ(bufsize, read(fd, buf, bufsize)) << strerror(errno); ASSERT_EQ(0, memcmp(buf, contents1, bufsize)); leak(fd); + free(contents); } /* Reading with sendfile should work (though it obviously won't be 0-copy) */ @@ -899,6 +900,8 @@ TEST_P(ReadAhead, readahead) { ASSERT_EQ(0, memcmp(rbuf, contents, bufsize)); leak(fd); + free(rbuf); + free(contents); } INSTANTIATE_TEST_CASE_P(RA, ReadAhead, diff --git a/tests/sys/fs/fusefs/write.cc b/tests/sys/fs/fusefs/write.cc index 4b4a2f7c4f3..506fefaa071 100644 --- a/tests/sys/fs/fusefs/write.cc +++ b/tests/sys/fs/fusefs/write.cc @@ -300,6 +300,8 @@ TEST_F(Write, append_to_cached) /* Write the new data. There should be no more read operations */ ASSERT_EQ(BUFSIZE, write(fd, CONTENTS, BUFSIZE)) << strerror(errno); leak(fd); + free(oldbuf); + free(oldcontents); } TEST_F(Write, append_direct_io) @@ -782,6 +784,8 @@ TEST_F(WriteCluster, clustering) << strerror(errno); } close(fd); + free(wbuf2x); + free(wbuf); } /* @@ -825,6 +829,7 @@ TEST_F(WriteCluster, DISABLED_cluster_write_err) << strerror(errno); } close(fd); + free(wbuf); } /* -- 2.45.0