Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Feb 2020 18:11:07 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357835 - head/tests/sys/fs/fusefs
Message-ID:  <202002121811.01CIB7Hw034974@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Wed Feb 12 18:11:07 2020
New Revision: 357835
URL: https://svnweb.freebsd.org/changeset/base/357835

Log:
  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
  MFC after:	2 weeks

Modified:
  head/tests/sys/fs/fusefs/read.cc
  head/tests/sys/fs/fusefs/write.cc

Modified: head/tests/sys/fs/fusefs/read.cc
==============================================================================
--- head/tests/sys/fs/fusefs/read.cc	Wed Feb 12 18:09:20 2020	(r357834)
+++ head/tests/sys/fs/fusefs/read.cc	Wed Feb 12 18:11:07 2020	(r357835)
@@ -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,

Modified: head/tests/sys/fs/fusefs/write.cc
==============================================================================
--- head/tests/sys/fs/fusefs/write.cc	Wed Feb 12 18:09:20 2020	(r357834)
+++ head/tests/sys/fs/fusefs/write.cc	Wed Feb 12 18:11:07 2020	(r357835)
@@ -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);
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002121811.01CIB7Hw034974>