From 1bc6d29c0db8a17b9163761e8d1575fdd38be0b1 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 4 Jun 2020 22:25:56 +0300 Subject: [PATCH] core: fix potential NPE in GetUtilityTokenBalance --- pkg/core/blockchain.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 4fecf3a9b..224e335af 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -927,7 +927,11 @@ func (bc *Blockchain) GetNEP5Balances(acc util.Uint160) *state.NEP5Balances { // GetUtilityTokenBalance returns utility token (GAS) balance for the acc. func (bc *Blockchain) GetUtilityTokenBalance(acc util.Uint160) util.Fixed8 { - return util.Fixed8(bc.GetNEP5Balances(acc).Trackers[bc.contracts.GAS.Hash].Balance) + bs, err := bc.dao.GetNEP5Balances(acc) + if err != nil { + return 0 + } + return util.Fixed8(bs.Trackers[bc.contracts.GAS.Hash].Balance) } // GetGoverningTokenBalance returns governing token (NEO) balance and the height