瀏覽代碼

Merge pull request #6157 from siddontang/siddontang/fix-overflow

raft: fix overflow
Xiang Li 9 年之前
父節點
當前提交
d3812ed664
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      raft/log.go

+ 1 - 1
raft/log.go

@@ -339,7 +339,7 @@ func (l *raftLog) mustCheckOutOfBounds(lo, hi uint64) error {
 		return ErrCompacted
 	}
 
-	length := l.lastIndex() - fi + 1
+	length := l.lastIndex() + 1 - fi
 	if lo < fi || hi > fi+length {
 		l.logger.Panicf("slice[%d,%d) out of bound [%d,%d]", lo, hi, fi, l.lastIndex())
 	}