routerrpc: fix payment address deep copy
using copy for a slice of size 0 will not copy anything so we need to first initialize the slice before we do the deep copy.
This commit is contained in:
1 file changed
+5
@@ -557,6 +557,7 @@ func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
|
||||
// If the payment addresses is specified, then we'll also populate that
|
||||
// now as well.
|
||||
payReq.PaymentAddr.WhenSome(func(addr [32]byte) {
|
||||
probeRequest.PaymentAddr = make([]byte, lntypes.HashSize)
|
||||
copy(probeRequest.PaymentAddr, addr[:])
|
||||
})
|
||||
|
||||
@@ -624,6 +625,10 @@ func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
|
||||
|
||||
// Copy the payment address if present.
|
||||
if len(probeRequest.PaymentAddr) > 0 {
|
||||
lspProbeRequest.PaymentAddr = make(
|
||||
[]byte, lntypes.HashSize,
|
||||
)
|
||||
|
||||
copy(
|
||||
lspProbeRequest.PaymentAddr,
|
||||
probeRequest.PaymentAddr,
|
||||
|
||||
Reference in new issue
Block a user