summaryrefslogtreecommitdiff
path: root/test/libapt/cdrom_test.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-06-18 17:33:15 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-08-10 17:25:25 +0200
commit3d8232bf97ce11818fb07813a71136484ea1a44a (patch)
treec7e1e3885e952f7ab8171e1cf4b425ddccb5606f /test/libapt/cdrom_test.cc
parentc3392a9fccc04129816057b1184c651171034376 (diff)
fix memory leaks reported by -fsanitize
Various small leaks here and there. Nothing particularily big, but still good to fix. Found by the sanitizers while running our testcases. Reported-By: gcc -fsanitize Git-Dch: Ignore
Diffstat (limited to 'test/libapt/cdrom_test.cc')
-rw-r--r--test/libapt/cdrom_test.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/test/libapt/cdrom_test.cc b/test/libapt/cdrom_test.cc
index 7257eaf1b..b4c51cdb0 100644
--- a/test/libapt/cdrom_test.cc
+++ b/test/libapt/cdrom_test.cc
@@ -91,7 +91,7 @@ TEST(CDROMTest,ReduceSourcelist)
}
TEST(CDROMTest, FindMountPointForDevice)
{
- char * tempfile = NULL;
+ std::string tempfile;
FileFd fd;
createTemporaryFile("mountpoints", fd, &tempfile,
"rootfs / rootfs rw 0 0\n"
@@ -109,7 +109,6 @@ TEST(CDROMTest, FindMountPointForDevice)
EXPECT_EQ("/boot/efi", FindMountPointForDevice("/dev/sda1"));
EXPECT_EQ("/tmp", FindMountPointForDevice("tmpfs"));
- if (tempfile != NULL)
- unlink(tempfile);
- free(tempfile);
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
}