[#1492] metabase: Ensure Unmarshal() is called on a cloned slice

The slice returned from bucket.Get() is only valid during the tx
lifetime. Cloning it is not necessary everywhere, but better safe than
sorry.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-11-13 10:07:32 +03:00 committed by Evgenii Stratonikov
parent b451de94c8
commit 8ed7a676d5
5 changed files with 10 additions and 7 deletions

View file

@ -1,6 +1,7 @@
package meta
import (
"bytes"
"context"
"fmt"
"time"
@ -215,7 +216,7 @@ func getSplitInfo(tx *bbolt.Tx, cnr cid.ID, key []byte) (*objectSDK.SplitInfo, e
splitInfo := objectSDK.NewSplitInfo()
err := splitInfo.Unmarshal(rawSplitInfo)
err := splitInfo.Unmarshal(bytes.Clone(rawSplitInfo))
if err != nil {
return nil, fmt.Errorf("can't unmarshal split info from root index: %w", err)
}