From ce1d1c6248ebc9a109f8ba594d3aeb294751023a Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 23 Feb 2023 23:18:05 +0800 Subject: [PATCH] discovery: fix heap escape on `cachedMsgs` --- discovery/gossiper.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index 15dfe796e2..ffcb2d0646 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -1900,9 +1900,10 @@ func (d *AuthenticatedGossiper) isPremature(chanID lnwire.ShortChannelID, pMsg := &processedNetworkMsg{msg: copied} // Add the network message. - cachedMsgs.msgs = append(cachedMsgs.msgs, pMsg) + msgs := cachedMsgs.msgs + msgs = append(msgs, pMsg) _, err = d.futureMsgs.Put(msgHeight, &cachedNetworkMsg{ - msgs: cachedMsgs.msgs, + msgs: msgs, }) if err != nil { log.Errorf("Adding future message got error: %v", err)