From 5fd46b0dcedef0b9b299e4aadc9300b9f815efd4 Mon Sep 17 00:00:00 2001 From: zhiqiangxu <652732310@qq.com> Date: Tue, 26 Mar 2024 17:28:09 +0800 Subject: [PATCH] channeldb: check return value of ReadWriteBucket --- channeldb/channel.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/channeldb/channel.go b/channeldb/channel.go index 7292fd6b01..bb63477147 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -1157,7 +1157,13 @@ func fetchFinalHtlcsBucketRw(tx kvdb.RwTx, func (c *OpenChannel) fullSync(tx kvdb.RwTx) error { // Fetch the outpoint bucket and check if the outpoint already exists. opBucket := tx.ReadWriteBucket(outpointBucket) + if opBucket == nil { + return ErrNoChanDBExists + } cidBucket := tx.ReadWriteBucket(chanIDBucket) + if cidBucket == nil { + return ErrNoChanDBExists + } var chanPointBuf bytes.Buffer if err := writeOutpoint(&chanPointBuf, &c.FundingOutpoint); err != nil { @@ -3513,6 +3519,9 @@ func (c *OpenChannel) CloseChannel(summary *ChannelCloseSummary, // Fetch the outpoint bucket to see if the outpoint exists or // not. opBucket := tx.ReadWriteBucket(outpointBucket) + if opBucket == nil { + return ErrNoChanDBExists + } // Add the closed outpoint to our outpoint index. This should // replace an open outpoint in the index.