Browse Source

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 <david@gibson.dropbear.id.au>
David Gibson 8 years ago
parent
commit
3c65e082a9
1 changed files with 3 additions and 1 deletions
  1. 3 1
      ccan/failtest/failtest.c

+ 3 - 1
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;
 		}
 	}