From df390df966d9e7e1d2a86a9f46844d65362d16d3 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 23 Apr 2019 20:04:23 -0700 Subject: [PATCH] watchtower/wtmock/client_db: clone bytes w/ nil --- watchtower/wtmock/client_db.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/watchtower/wtmock/client_db.go b/watchtower/wtmock/client_db.go index fc0402de7..5853c363f 100644 --- a/watchtower/wtmock/client_db.go +++ b/watchtower/wtmock/client_db.go @@ -110,7 +110,7 @@ func (m *ClientDB) CreateClientSession(session *wtdb.ClientSession) error { Policy: session.Policy, SeqNum: session.SeqNum, TowerLastApplied: session.TowerLastApplied, - RewardPkScript: session.RewardPkScript, + RewardPkScript: cloneBytes(session.RewardPkScript), CommittedUpdates: make(map[uint16]*wtdb.CommittedUpdate), AckedUpdates: make(map[uint16]wtdb.BackupID), } @@ -228,7 +228,12 @@ func (m *ClientDB) AddChanPkScript(chanID lnwire.ChannelID, pkScript []byte) err } func cloneBytes(b []byte) []byte { + if b == nil { + return nil + } + bb := make([]byte, len(b)) copy(bb, b) + return bb }