Skip to content

Commit 8cef232

Browse files
Fix possible panic on filestore.go (#6912)
Fix to prevent this panic seen in tests: ``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb69322] goroutine 183 [running]: github.com/nats-io/nats-server/v2/server.(*fileStore).cleanupOldMeta(0x0) server/filestore.go:1984 +0x42 created by github.com/nats-io/nats-server/v2/server.newFileStoreWithCreated.func4 in goroutine 143 server/filestore.go:519 +0xb1 ``` Signed-off-by: Waldemar Quevedo <[email protected]>
2 parents 3ccb5d1 + 73c8420 commit 8cef232

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/filestore.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,9 @@ func newFileStoreWithCreated(fcfg FileStoreConfig, cfg StreamConfig, created tim
516516
// Also make sure we get rid of old idx and fss files on return.
517517
// Do this in separate go routine vs inline and at end of processing.
518518
defer func() {
519-
go fs.cleanupOldMeta()
519+
if fs != nil {
520+
go fs.cleanupOldMeta()
521+
}
520522
}()
521523

522524
// Lock while we do enforcements and removals.

0 commit comments

Comments
 (0)