mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
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 .
This commit is contained in:
parent
18834a9191
commit
3232605524
1 changed files with 1 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue