[#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>
This commit is contained in:
Leonard Lyubich 2020-09-28 16:07:48 +03:00 committed by Alex Vanin
parent 7813b90554
commit 759605410a

View file

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