Skip to content

Commit 5fd46b0

Browse files
committed
channeldb: check return value of ReadWriteBucket
1 parent d3e5b2f commit 5fd46b0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

channeldb/channel.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,13 @@ func fetchFinalHtlcsBucketRw(tx kvdb.RwTx,
11571157
func (c *OpenChannel) fullSync(tx kvdb.RwTx) error {
11581158
// Fetch the outpoint bucket and check if the outpoint already exists.
11591159
opBucket := tx.ReadWriteBucket(outpointBucket)
1160+
if opBucket == nil {
1161+
return ErrNoChanDBExists
1162+
}
11601163
cidBucket := tx.ReadWriteBucket(chanIDBucket)
1164+
if cidBucket == nil {
1165+
return ErrNoChanDBExists
1166+
}
11611167

11621168
var chanPointBuf bytes.Buffer
11631169
if err := writeOutpoint(&chanPointBuf, &c.FundingOutpoint); err != nil {
@@ -3513,6 +3519,9 @@ func (c *OpenChannel) CloseChannel(summary *ChannelCloseSummary,
35133519
// Fetch the outpoint bucket to see if the outpoint exists or
35143520
// not.
35153521
opBucket := tx.ReadWriteBucket(outpointBucket)
3522+
if opBucket == nil {
3523+
return ErrNoChanDBExists
3524+
}
35163525

35173526
// Add the closed outpoint to our outpoint index. This should
35183527
// replace an open outpoint in the index.

0 commit comments

Comments
 (0)