From f76560a4105e3827b6fb820f42307bbb93ae0e31 Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Wed, 8 Jan 2025 09:43:56 -0500 Subject: [PATCH] fix: return error early on nil block/block header Signed-off-by: Chris Gianelloni --- protocol/chainsync/client.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/protocol/chainsync/client.go b/protocol/chainsync/client.go index 3f2a344e..5755614a 100644 --- a/protocol/chainsync/client.go +++ b/protocol/chainsync/client.go @@ -635,6 +635,11 @@ func (c *Client) handleRollForward(msgGeneric protocol.Message) error { } } if firstBlockChan != nil { + if blockHeader == nil { + err := fmt.Errorf("missing block header") + firstBlockChan <- clientPointResult{error: err} + return err + } blockHash, err := hex.DecodeString(blockHeader.Hash()) if err != nil { firstBlockChan <- clientPointResult{error: err} @@ -677,6 +682,11 @@ func (c *Client) handleRollForward(msgGeneric protocol.Message) error { } } if firstBlockChan != nil { + if block == nil { + err := fmt.Errorf("missing block") + firstBlockChan <- clientPointResult{error: err} + return err + } blockHash, err := hex.DecodeString(block.Hash()) if err != nil { firstBlockChan <- clientPointResult{error: err}