From 935bafa5a381ed22ef73a5e8cbe8d601698e99b8 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Thu, 16 Jan 2025 15:25:46 +0000 Subject: [PATCH] Fix potential panic when subscribing to topic fails (#830) Avoid referencing subscription when constructing an error message as it may be nil when subscription fails. --- host.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host.go b/host.go index a5dd1efc..576b2d47 100644 --- a/host.go +++ b/host.go @@ -640,7 +640,7 @@ func (h *gpbftRunner) startPubsub() (<-chan gpbft.ValidatedMessage, error) { ) sub, err := h.topic.Subscribe(pubsub.WithBufferSize(subBufferSize)) if err != nil { - return nil, fmt.Errorf("could not subscribe to pubsub topic: %s: %w", sub.Topic(), err) + return nil, fmt.Errorf("could not subscribe to pubsub topic: %s: %w", h.topic, err) } messageQueue := make(chan gpbft.ValidatedMessage, msgQueueBufferSize)