fix nil pointer dereference in copyRPC

This commit is contained in:
vyzo 2018-08-28 21:17:00 +03:00
parent de4adefafb
commit 73b338aa6d
1 changed files with 10 additions and 7 deletions

17
comm.go
View File

@ -124,17 +124,20 @@ func rpcWithControl(msgs []*pb.Message,
}
func copyRPC(rpc *RPC) *RPC {
return &RPC{
res := &RPC{
RPC: pb.RPC{
Subscriptions: rpc.Subscriptions,
Publish: rpc.Publish,
Control: &pb.ControlMessage{
Ihave: rpc.Control.Ihave,
Iwant: rpc.Control.Iwant,
Graft: rpc.Control.Graft,
Prune: rpc.Control.Prune,
},
},
from: rpc.from,
}
if rpc.Control != nil {
res.Control = &pb.ControlMessage{
Ihave: rpc.Control.Ihave,
Iwant: rpc.Control.Iwant,
Graft: rpc.Control.Graft,
Prune: rpc.Control.Prune,
}
}
return res
}