From: Cody P Schafer Date: Sun, 16 Aug 2015 22:54:37 +0000 (-0400) Subject: configurator: avoid leaks that LeakSanitizer doesn't like X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=d88372302ac7d1b5e6d6def90df16c3b9fcd8a4f configurator: avoid leaks that LeakSanitizer doesn't like These leaks aren't really an issue since they are completely bounded, but if one is building with leak sanitizer enabled (as -fsanitize=address does in gcc-5.1), it kills the configurator, which isn't very useful for us. Add the few free() calls it's looking for. This is not an actual code issue, they just workaround some optional compiler peculiarities. Signed-off-by: Cody P Schafer Signed-off-by: Rusty Russell (split off leak change) --- diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c index f4edb8ee..a162ee67 100644 --- a/tools/configurator/configurator.c +++ b/tools/configurator/configurator.c @@ -430,6 +430,9 @@ static bool run_test(const char *cmd, struct test *test) test->done = true; return test->answer; } + if (deps[len]) + free(dep); + deps += len; deps += strspn(deps, " "); } @@ -549,6 +552,7 @@ int main(int argc, const char *argv[]) cmd = connect_args(argv, " -o " OUTPUT_FILE " " INPUT_FILE); for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) run_test(cmd, &tests[i]); + free(cmd); unlink(OUTPUT_FILE); unlink(INPUT_FILE); @@ -560,7 +564,9 @@ int main(int argc, const char *argv[]) printf("#define _GNU_SOURCE /* Always use GNU extensions. */\n"); printf("#endif\n"); printf("#define CCAN_COMPILER \"%s\"\n", argv[1]); - printf("#define CCAN_CFLAGS \"%s\"\n\n", connect_args(argv+1, "")); + cmd = connect_args(argv+1, ""); + printf("#define CCAN_CFLAGS \"%s\"\n\n", cmd); + free(cmd); /* This one implies "#include