summaryrefslogtreecommitdiff
path: root/test/libapt/file-helpers.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/file-helpers.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/file-helpers.cc')
-rw-r--r--test/libapt/file-helpers.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/test/libapt/file-helpers.cc b/test/libapt/file-helpers.cc
index 5edb9a9fe..387192868 100644
--- a/test/libapt/file-helpers.cc
+++ b/test/libapt/file-helpers.cc
@@ -53,20 +53,19 @@ void helperCreateLink(std::string const &dir, std::string const &targetname, std
link.append(linkname);
ASSERT_EQ(0, symlink(target.c_str(), link.c_str()));
}
-void helperCreateTemporaryFile(std::string const &id, FileFd &fd, char * * const filename, char const * const content)
+void helperCreateTemporaryFile(std::string const &id, FileFd &fd, std::string * const filename, char const * const content)
{
std::string name("apt-test-");
name.append(id).append(".XXXXXXXX");
char * tempfile = strdup(name.c_str());
+ ASSERT_STRNE(NULL, tempfile);
int tempfile_fd = mkstemp(tempfile);
ASSERT_NE(-1, tempfile_fd);
if (filename != NULL)
*filename = tempfile;
else
- {
unlink(tempfile);
- free(tempfile);
- }
+ free(tempfile);
EXPECT_TRUE(fd.OpenDescriptor(tempfile_fd, FileFd::ReadWrite));
if (content != NULL)