Skip to content

Commit a8528ac

Browse files
committed
bitcoin/block.c: add null check after pull_bitcoin_tx_only
Commit 40dd780 switched from pull_bitcoin_tx to pull_bitcoin_tx_only but did not add a null check, causing a segfault (FATAL SIGNAL 11) if pull_bitcoin_tx_only returns NULL due to a malformed block response from bitcoind. Add null check consistent with existing patterns in the codebase and with pull_bitcoin_tx itself. Fixes: 40dd780 bitcoin_block_from_hex: avoid creating PSBT wrappers for finalized block txs
1 parent daa3b06 commit a8528ac

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

bitcoin/block.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ bitcoin_block_from_hex(const tal_t *ctx, const struct chainparams *chainparams,
210210
b->txids = tal_arr(b, struct bitcoin_txid, num);
211211
for (i = 0; i < num; i++) {
212212
b->tx[i] = pull_bitcoin_tx_only(b->tx, &p, &len);
213+
if (!b->tx[i])
214+
return tal_free(b);
213215
b->tx[i]->chainparams = chainparams;
214216
bitcoin_txid(b->tx[i], &b->txids[i]);
215217
}

0 commit comments

Comments
 (0)