From 6ec72393c4be87e89e1d8af0501cfb7e48a1090d Mon Sep 17 00:00:00 2001 From: "Matt T. Proud" Date: Tue, 15 Apr 2014 11:51:31 +0200 Subject: [PATCH] Correct size of unmarshalling destination buffer. The format header size is not deducted from the size of the byte stream when calculating the output buffer size for samples. I have yet to notice problems directly as a result of this, but it is good to fix. Change-Id: Icb07a0718366c04ddac975d738a6305687773af0 --- storage/metric/sample.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/metric/sample.go b/storage/metric/sample.go index fff0f9d9c9..f6016625f4 100644 --- a/storage/metric/sample.go +++ b/storage/metric/sample.go @@ -171,7 +171,7 @@ func (v Values) marshal() []byte { // unmarshalValues decodes marshalled samples and returns them as Values. func unmarshalValues(buf []byte) Values { - n := len(buf) / sampleSize + n := (len(buf) - formatVersionSize) / sampleSize // Setting the value of a given slice index is around 15% faster than doing // an append, even if the slice already has the required capacity. For this // reason, we already set the full target length here.