From 3c65e082a9547992222a9f379f2484cceaaedfa8 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Sun, 2 Apr 2017 19:06:06 +1000 Subject: [PATCH] failtest: Remove memory leak Somewhat ironically, a path in failtest related to detecting leaks in the tested program itself leaks memory. This corrects it. Detected by Coverity. Signed-off-by: David Gibson --- ccan/failtest/failtest.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ccan/failtest/failtest.c b/ccan/failtest/failtest.c index aab28dd4..c61ce442 100644 --- a/ccan/failtest/failtest.c +++ b/ccan/failtest/failtest.c @@ -613,8 +613,10 @@ static NORETURN void failtest_cleanup(bool forced_cleanup, int status) /* But their program shouldn't leak, even on failure. */ if (!forced_cleanup && i->can_leak) { + char *p = failpath_string(); printf("Leak at %s:%u: --failpath=%s\n", - i->file, i->line, failpath_string()); + i->file, i->line, p); + free(p); status = 1; } } -- 2.39.2