From 512c73cef9f91c7ce05149efdd3125512bf9e25e 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 e61abe756..c0edb40b3 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -456,8 +456,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 }