From 5ef0ed31266eea962f75e6132cdc354d769c6368 Mon Sep 17 00:00:00 2001 From: Dusty Daemon Date: Tue, 13 May 2025 13:49:37 -0400 Subject: [PATCH] psbt: unused code path could leak If `wally_psbt_extract` fails the function returns early leaking psbt, if it was `taken()`. Throw it on tmpctx so its not leaked in this case. Changelog-None --- bitcoin/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoin/tx.c b/bitcoin/tx.c index 869bc6897..4c1a63de6 100644 --- a/bitcoin/tx.c +++ b/bitcoin/tx.c @@ -553,7 +553,7 @@ struct bitcoin_tx *bitcoin_tx_with_psbt(const tal_t *ctx, struct wally_psbt *psb size_t locktime; if (!taken(psbt)) - psbt = clone_psbt(NULL, psbt); + psbt = clone_psbt(tmpctx, psbt); wally_psbt_get_locktime(psbt, &locktime); struct bitcoin_tx *tx = bitcoin_tx(ctx, chainparams,