From 6df173dbf3f90db367556172f3c1dca92d170b48 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 1 Oct 2024 09:29:27 +0200 Subject: [PATCH] journal: only destroy the connection if it is set Prevent re-use of a destroyed connection by setting it to `nil`. This way it is also safe to call `Destroy()` multiple times without causing a panic. Signed-off-by: Niels de Vos --- internal/journal/volumegroupjournal.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/journal/volumegroupjournal.go b/internal/journal/volumegroupjournal.go index 7d6a2b77e..99ad8dafd 100644 --- a/internal/journal/volumegroupjournal.go +++ b/internal/journal/volumegroupjournal.go @@ -143,7 +143,10 @@ func (vgc *VolumeGroupJournalConfig) Connect( // Destroy frees any resources and invalidates the journal connection. func (vgjc *volumeGroupJournalConnection) Destroy() { - vgjc.connection.Destroy() + if vgjc.connection != nil { + vgjc.connection.Destroy() + vgjc.connection = nil + } } // VolumeGroupData contains the GroupUUID and VolumeGroupAttributes for a