From 057fb2120b5628420147a11522c6355ae04ce847 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 19 Dec 2022 10:14:34 -0800 Subject: [PATCH] lib/storage: properly set buf capacity inside marshalMetricID Previously it was always set to 0. In theory this could result into incorrect marshaling of metricIDs. The issue has been introduced in 5e4dfe50c6b30aa49aefd911176433783a3aca4a --- lib/storage/index_db.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index a28a8492f4..2eee7b4703 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -443,8 +443,8 @@ func marshalMetricIDs(dst []byte, metricIDs []uint64) []byte { var buf []byte sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) sh.Data = uintptr(unsafe.Pointer(&metricIDs[0])) - sh.Cap = sh.Len - sh.Len = 8 * len(metricIDs) + sh.Cap = 8 * len(metricIDs) + sh.Len = sh.Cap dst = append(dst, buf...) return dst }