Remove possible nil pointer dereferences.
Results from FetchTxByShaList must each be checked for a nil Err and a non-nil Tx. Fix this issue in two places where these conditions were not being checked.
This commit is contained in:
parent
d44d253dff
commit
5bfc9c7eed
1 changed files with 11 additions and 6 deletions
17
rpcserver.go
17
rpcserver.go
|
@ -859,15 +859,18 @@ func jsonWSRead(walletNotification chan []byte, replychan chan *btcjson.Reply, b
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
txList := s.server.db.FetchTxByShaList(txShaList)
|
txList := s.server.db.FetchTxByShaList(txShaList)
|
||||||
for j := range txList {
|
for _, txReply := range txList {
|
||||||
for _, txout := range txList[j].Tx.TxOut {
|
if txReply.Err != nil || txReply.Tx == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, txout := range txReply.Tx.TxOut {
|
||||||
_, txaddrhash, err := btcscript.ScriptToAddrHash(txout.PkScript)
|
_, txaddrhash, err := btcscript.ScriptToAddrHash(txout.PkScript)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !bytes.Equal(addrhash, txaddrhash) {
|
if !bytes.Equal(addrhash, txaddrhash) {
|
||||||
reply := btcjson.Reply{
|
reply := btcjson.Reply{
|
||||||
Result: txList[j].Sha,
|
Result: txReply.Sha,
|
||||||
Error: nil,
|
Error: nil,
|
||||||
Id: &message.Id,
|
Id: &message.Id,
|
||||||
}
|
}
|
||||||
|
@ -1253,9 +1256,11 @@ func (s *rpcServer) NotifyNewTxListeners(db btcdb.Db, block *btcutil.Block) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
txList := db.FetchTxByShaList(txShaList)
|
txList := db.FetchTxByShaList(txShaList)
|
||||||
for _, tx := range txList {
|
for _, txReply := range txList {
|
||||||
go s.newBlockNotifyCheckTxIn(tx.Tx.TxIn)
|
if txReply.Err == nil && txReply.Tx != nil {
|
||||||
go s.newBlockNotifyCheckTxOut(db, block, tx)
|
go s.newBlockNotifyCheckTxIn(txReply.Tx.TxIn)
|
||||||
|
go s.newBlockNotifyCheckTxOut(db, block, txReply)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue