failtest: Remove memory leak
[ccan] / ccan / failtest / failtest.c
index aab28dd43472449493297d223afafa21d4e667c2..c61ce442a5d03b39444a87a468514f23c6f3c962 100644 (file)
@@ -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;
                }
        }