From 939a7b2b1881a0658ee9f9711cf6b808aedc9f29 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 19 Sep 2022 10:24:26 +0930 Subject: [PATCH] db/postgres: avoid memleak. ``` "label": "db/db_postgres.c:294:char[]", "backtrace": [ "ccan/ccan/tal/tal.c:442 (tal_alloc_)", "ccan/ccan/tal/tal.c:471 (tal_alloc_arr_)", "ccan/ccan/tal/str/str.c:91 (tal_vfmt_)", "ccan/ccan/tal/str/str.c:44 (tal_fmt_)", "db/db_postgres.c:294 (db_postgres_delete_columns)", "wallet/db.c:1546 (migrate_payments_scids_as_integers)", "wallet/db.c:986 (db_migrate)", "wallet/db.c:1019 (db_setup)", "wallet/wallet.c:101 (wallet_new)", "lightningd/lightningd.c:1023 (main)", "../csu/libc-start.c:308 (__libc_start_main)" ], "parents": [ "db/utils.c:317:struct db", "lightningd/lightningd.c:107:struct lightningd" ] ``` Signed-off-by: Rusty Russell --- db/db_postgres.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/db_postgres.c b/db/db_postgres.c index 19ff4d52c..0d3eb7f0b 100644 --- a/db/db_postgres.c +++ b/db/db_postgres.c @@ -291,7 +291,7 @@ static bool db_postgres_delete_columns(struct db *db, { char *cmd; - cmd = tal_fmt(db, "ALTER TABLE %s ", tablename); + cmd = tal_fmt(tmpctx, "ALTER TABLE %s ", tablename); for (size_t i = 0; i < num_cols; i++) { if (i != 0) tal_append_fmt(&cmd, ", ");