mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-15 19:31:03 -05:00
go/store/nbs: journal.go: Fix some nil dereference panics is rarely executed error handling code regarding a journal manifest in readOnly mode.
This commit is contained in:
@@ -528,7 +528,9 @@ func newJournalManifest(ctx context.Context, dir string) (m *journalManifest, er
|
||||
var f *os.File
|
||||
f, err = openIfExists(filepath.Join(dir, manifestFileName))
|
||||
if err != nil {
|
||||
_ = lock.Unlock()
|
||||
if lock != nil {
|
||||
_ = lock.Unlock()
|
||||
}
|
||||
return nil, err
|
||||
} else if f == nil {
|
||||
return m, nil
|
||||
@@ -538,17 +540,23 @@ func newJournalManifest(ctx context.Context, dir string) (m *journalManifest, er
|
||||
err = cerr // keep first error
|
||||
}
|
||||
if err != nil {
|
||||
_ = lock.Unlock()
|
||||
if lock != nil {
|
||||
_ = lock.Unlock()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
var ok bool
|
||||
ok, _, err = m.ParseIfExists(ctx, &Stats{}, nil)
|
||||
if err != nil {
|
||||
_ = lock.Unlock()
|
||||
if lock != nil {
|
||||
_ = lock.Unlock()
|
||||
}
|
||||
return nil, err
|
||||
} else if !ok {
|
||||
_ = lock.Unlock()
|
||||
if lock != nil {
|
||||
_ = lock.Unlock()
|
||||
}
|
||||
return nil, ErrUnreadableManifest
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user