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 <da...@gibson.dropbear.id.au>
---
 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 aab28dd..c61ce44 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.9.3

_______________________________________________
ccan mailing list
ccan@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/ccan

Reply via email to