From: David Gibson Date: Sun, 2 Apr 2017 09:06:06 +0000 (+1000) Subject: failtest: Remove memory leak X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=3c65e082a9547992222a9f379f2484cceaaedfa8 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 --- 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; } }