From 759605410ae4f5466de9bf1f406b738e756a83e0 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 28 Sep 2020 16:07:48 +0300 Subject: [PATCH] [#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 --- pkg/services/object/range/chain.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/services/object/range/chain.go b/pkg/services/object/range/chain.go index 18e85a2ed..8b45ca9eb 100644 --- a/pkg/services/object/range/chain.go +++ b/pkg/services/object/range/chain.go @@ -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, + } } }