psbt-fix: set to NULL, which will cleanup dangling pointer

On July 18th, @jgriffiths wrote:

> You need to set this to NULL after freeing it, otherwise if line 72 returns you have a dangling pointer and potential later use-after-free here. Alternately use wally_psbt_set_input_final_witness(NULL) which will free any existing witness and set the value to NULL.

Reported-By: @jgriffiths
This commit is contained in:
niftynei 2023-12-05 02:03:20 -06:00 committed by Rusty Russell
parent b250bca429
commit 7717f6e4df

View File

@ -65,7 +65,7 @@ psbt_input_set_final_witness_stack(const tal_t *ctx,
size_t size, max = tal_count(data);
bool ok;
wally_tx_witness_stack_free(in->final_witness);
wally_psbt_input_set_final_witness(in, NULL);
/* FIXME: return an error?? */
if (!next_size(&data, &max, &size))