Fix rbf.Cursor.Close() panic

This commit is contained in:
Ben Johnson 2021-01-07 11:28:46 -07:00
parent 17e010cca2
commit 93f06e0f9d

View file

@ -1388,7 +1388,10 @@ func (c *Cursor) difference(key uint64, data *roaring.Container) (bool, error) {
func (c *Cursor) Close() {
if c == nil {
panic("cannot Close nil Cursor")
} else if c.tx == nil || c.tx.db == nil {
return // already closed
}
tx := c.tx
c.tx = nil // allow tx to be garbage collected.