From e902d9af56147a4453dbcfd95fd03206085cd400 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 4 Jun 2019 03:56:25 +0930 Subject: [PATCH] cli/lightning-cli: free eveything on exit. It's not required, but it means valgrind won't complain about leaks. Suggested-by: @m-schmoock Signed-off-by: Rusty Russell --- cli/lightning-cli.c | 4 ++++ cli/test/run-large-input.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/cli/lightning-cli.c b/cli/lightning-cli.c index c7ff930d8..ecb9c03f9 100644 --- a/cli/lightning-cli.c +++ b/cli/lightning-cli.c @@ -604,6 +604,8 @@ int main(int argc, char *argv[]) tal_free(rpc_filename); tal_free(ctx); opt_free_table(); + free(resp); + free(toks); return 0; } @@ -618,5 +620,7 @@ int main(int argc, char *argv[]) tal_free(rpc_filename); tal_free(ctx); opt_free_table(); + free(resp); + free(toks); return 1; } diff --git a/cli/test/run-large-input.c b/cli/test/run-large-input.c index 7217bb61c..3edd2f8fc 100644 --- a/cli/test/run-large-input.c +++ b/cli/test/run-large-input.c @@ -16,6 +16,7 @@ int test_getpid(void); int test_printf(const char *format, ...); void *test_malloc(size_t n); void *test_realloc(void *p, size_t n); +void test_free(void *p); #define main test_main #define read test_read @@ -25,6 +26,7 @@ void *test_realloc(void *p, size_t n); #define printf test_printf #define malloc test_malloc #define realloc test_realloc +#define free test_free #include "../lightning-cli.c" #undef main @@ -71,6 +73,11 @@ void *test_realloc(void *p, size_t n) return p; } +void test_free(void *p) +{ + tal_free(p); +} + ssize_t test_read(int fd UNUSED, void *buf, size_t len) { if (len > max_read_return)