Browse Source

raft: fix overflow

siddontang 9 years ago
parent
commit
f8ee322b08
1 changed files with 1 additions and 1 deletions
  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
 		return ErrCompacted
 	}
 	}
 
 
-	length := l.lastIndex() - fi + 1
+	length := l.lastIndex() + 1 - fi
 	if lo < fi || hi > fi+length {
 	if lo < fi || hi > fi+length {
 		l.logger.Panicf("slice[%d,%d) out of bound [%d,%d]", lo, hi, fi, l.lastIndex())
 		l.logger.Panicf("slice[%d,%d) out of bound [%d,%d]", lo, hi, fi, l.lastIndex())
 	}
 	}