Skip to content

Commit 1c4bcc3

Browse files
committed
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.
1 parent cb3991e commit 1c4bcc3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lnrpc/routerrpc/router_server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
557557
// If the payment addresses is specified, then we'll also populate that
558558
// now as well.
559559
payReq.PaymentAddr.WhenSome(func(addr [32]byte) {
560+
probeRequest.PaymentAddr = make([]byte, lntypes.HashSize)
560561
copy(probeRequest.PaymentAddr, addr[:])
561562
})
562563

@@ -624,6 +625,10 @@ func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
624625

625626
// Copy the payment address if present.
626627
if len(probeRequest.PaymentAddr) > 0 {
628+
lspProbeRequest.PaymentAddr = make(
629+
[]byte, lntypes.HashSize,
630+
)
631+
627632
copy(
628633
lspProbeRequest.PaymentAddr,
629634
probeRequest.PaymentAddr,

0 commit comments

Comments
 (0)