From bd5f4e0344d95a078984cf2cd21420fd4ed52d5c Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 12 May 2020 14:53:15 +0300 Subject: [PATCH] lib/storage: properly initialize part struct before trying to close it on error This should prevent from nil pointer dereference bug at https://github.com/VictoriaMetrics/VictoriaMetrics/issues/468 . --- lib/storage/part.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/storage/part.go b/lib/storage/part.go index 7334f6b2d..84bd06d46 100644 --- a/lib/storage/part.go +++ b/lib/storage/part.go @@ -117,6 +117,7 @@ func newPart(ph *partHeader, path string, size uint64, metaindexReader filestrea p.indexFile = indexFile p.metaindex = metaindex + p.ibCache = newIndexBlockCache() if len(errors) > 0 { // Return only the first error, since it has no sense in returning all errors. @@ -125,8 +126,6 @@ func newPart(ph *partHeader, path string, size uint64, metaindexReader filestrea return nil, err } - p.ibCache = newIndexBlockCache() - return &p, nil }