From 6363a756c08338afe59b2e5765b8a61143711df2 Mon Sep 17 00:00:00 2001 From: sora233 Date: Sun, 10 Jan 2021 21:36:17 +0800 Subject: [PATCH] fix set transaction leak --- buntdb.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/buntdb.go b/buntdb.go index 02708d9..37ac20f 100644 --- a/buntdb.go +++ b/buntdb.go @@ -1390,7 +1390,9 @@ func (tx *Tx) Set(key, value string, opts *SetOptions) (previousValue string, // create a rollback entry with a nil value. A nil value indicates // that the entry should be deleted on rollback. When the value is // *not* nil, that means the entry should be reverted. - tx.wc.rollbackItems[key] = nil + if _, ok := tx.wc.rollbackItems[key]; !ok { + tx.wc.rollbackItems[key] = nil + } } else { // A previous item already exists in the database. Let's create a // rollback entry with the item as the value. We need to check the