From 71cb30cc58e156a42712e003a2bf1afb2afb5ce0 Mon Sep 17 00:00:00 2001 From: chengshiwen Date: Thu, 11 Jul 2024 18:05:08 +0800 Subject: [PATCH] fix nil pointer dereference in marshal binary of join cluster response #15 --- coordinator/rpc.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/coordinator/rpc.go b/coordinator/rpc.go index bf95d97..d8ef1ef 100644 --- a/coordinator/rpc.go +++ b/coordinator/rpc.go @@ -1326,10 +1326,12 @@ type JoinClusterResponse struct { func (r *JoinClusterResponse) MarshalBinary() ([]byte, error) { var pb internal.JoinClusterResponse - pb.Node = &internal.NodeInfo{ - ID: proto.Uint64(r.Node.ID), - Addr: proto.String(r.Node.Addr), - TCPAddr: proto.String(r.Node.TCPAddr), + if r.Node != nil { + pb.Node = &internal.NodeInfo{ + ID: proto.Uint64(r.Node.ID), + Addr: proto.String(r.Node.Addr), + TCPAddr: proto.String(r.Node.TCPAddr), + } } if r.Err != nil { pb.Err = proto.String(r.Err.Error())