mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-13 22:53:27 +01:00
Merge pull request #4803
fa3f756b
unit_tests: fix leak when the test check fails (moneromooo-monero)
This commit is contained in:
commit
afaff5fb77
@ -49,7 +49,8 @@ TEST(notify, works)
|
|||||||
tmp = "/tmp";
|
tmp = "/tmp";
|
||||||
static const char *filename = "monero-notify-unit-test-XXXXXX";
|
static const char *filename = "monero-notify-unit-test-XXXXXX";
|
||||||
const size_t len = strlen(tmp) + 1 + strlen(filename);
|
const size_t len = strlen(tmp) + 1 + strlen(filename);
|
||||||
char *name_template = (char*)malloc(len + 1);
|
std::unique_ptr<char[]> name_template_((char*)malloc(len + 1));
|
||||||
|
char *name_template = name_template_.get();
|
||||||
ASSERT_TRUE(name_template != NULL);
|
ASSERT_TRUE(name_template != NULL);
|
||||||
snprintf(name_template, len + 1, "%s/%s", tmp, filename);
|
snprintf(name_template, len + 1, "%s/%s", tmp, filename);
|
||||||
int fd = mkstemp(name_template);
|
int fd = mkstemp(name_template);
|
||||||
@ -75,5 +76,4 @@ TEST(notify, works)
|
|||||||
ASSERT_TRUE(s == "1111111111111111111111111111111111111111111111111111111111111111");
|
ASSERT_TRUE(s == "1111111111111111111111111111111111111111111111111111111111111111");
|
||||||
|
|
||||||
boost::filesystem::remove(name_template);
|
boost::filesystem::remove(name_template);
|
||||||
free(name_template);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user