From 062da00d10c37fe0eab2bc1136d02423c674fbbd Mon Sep 17 00:00:00 2001 From: Jackson Owens Date: Fri, 10 Feb 2023 15:52:23 -0500 Subject: [PATCH] storage: fix CheckSSTConflicts access of undefined buffer This is a backport of the CheckSSTConflicts bug fix contained within #96685. Previously, CheckSSTConflicts would improperly access an invalid iterator's `UnsafeKey`, using it to seek another iterator. Epic: None Release note: None --- pkg/storage/sst.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/storage/sst.go b/pkg/storage/sst.go index 1c5add791f8a..a720ab2bb337 100644 --- a/pkg/storage/sst.go +++ b/pkg/storage/sst.go @@ -1003,7 +1003,7 @@ func CheckSSTConflicts( // 2) the ext iterator became invalid // 3) both iterators changed keys and the sst iterator's key is further // ahead. - if extChangedKeys && (!sstChangedKeys || (!extOK && sstOK) || extIter.UnsafeKey().Key.Compare(sstIter.UnsafeKey().Key) < 0) { + if sstOK && extChangedKeys && (!sstChangedKeys || !extOK || extIter.UnsafeKey().Key.Compare(sstIter.UnsafeKey().Key) < 0) { extIter.SeekGE(MVCCKey{Key: sstIter.UnsafeKey().Key}) extOK, extErr = extIter.Valid() }