[#53] object/range: Do not add chain element without the need

In previous implementation one excess element could be added to the chain.
Add previous sibling presence check to prevent this.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
support/v0.27
Leonard Lyubich 2020-09-28 16:07:48 +03:00 committed by Alex Vanin
parent 7813b90554
commit 759605410a
1 changed files with 5 additions and 3 deletions

View File

@ -97,9 +97,11 @@ func (c *rangeTraverser) pushHeader(obj *object.Object) {
c.chain = c.chain.prev
c.chain.prev = &rangeChain{
next: c.chain,
id: obj.GetPreviousID(),
if prev := obj.GetPreviousID(); prev != nil {
c.chain.prev = &rangeChain{
next: c.chain,
id: prev,
}
}
}