From 6197bd2b828804b9b294a0bc7b95371965264e26 Mon Sep 17 00:00:00 2001 From: niftynei Date: Thu, 21 May 2020 14:42:39 -0500 Subject: [PATCH] psbt: check return value on init for wally input --- bitcoin/tx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bitcoin/tx.c b/bitcoin/tx.c index fe25cc355..48ae5574b 100644 --- a/bitcoin/tx.c +++ b/bitcoin/tx.c @@ -158,14 +158,18 @@ int bitcoin_tx_add_input(struct bitcoin_tx *tx, const struct bitcoin_txid *txid, struct amount_sat amount, u8 *script) { struct wally_tx_input *input; + int wally_err; size_t i; assert(tx->wtx != NULL); i = tx->wtx->num_inputs; - wally_tx_input_init_alloc(txid->shad.sha.u.u8, - sizeof(struct bitcoin_txid), outnum, sequence, - script, tal_bytelen(script), - NULL /* Empty witness stack */, &input); + wally_err = wally_tx_input_init_alloc(txid->shad.sha.u.u8, + sizeof(struct bitcoin_txid), + outnum, sequence, + script, tal_bytelen(script), + NULL /* Empty witness stack */, + &input); + assert(wally_err == WALLY_OK); input->features = chainparams->is_elements ? WALLY_TX_IS_ELEMENTS : 0; wally_tx_add_input(tx->wtx, input); psbt_add_input(tx->psbt, input, i);