aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-07-18 20:26:22 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-07-18 20:26:22 +0800
commit61a20cb56d5c135bc5525aa0089671da26572a78 (patch)
treedbe903be29cebcc63274d53f01e3286eb27bca15 /core
parentf088c650a58c1eff8b2b6fe51d7e4b8e9762200f (diff)
downloadgo-tangerine-61a20cb56d5c135bc5525aa0089671da26572a78.tar
go-tangerine-61a20cb56d5c135bc5525aa0089671da26572a78.tar.gz
go-tangerine-61a20cb56d5c135bc5525aa0089671da26572a78.tar.bz2
go-tangerine-61a20cb56d5c135bc5525aa0089671da26572a78.tar.lz
go-tangerine-61a20cb56d5c135bc5525aa0089671da26572a78.tar.xz
go-tangerine-61a20cb56d5c135bc5525aa0089671da26572a78.tar.zst
go-tangerine-61a20cb56d5c135bc5525aa0089671da26572a78.zip
core: check error before accessing potentially nil block
Diffstat (limited to 'core')
-rw-r--r--core/genesis.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/genesis.go b/core/genesis.go
index 57809fe73..87bab2520 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -164,7 +164,10 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
log.Info("Writing custom genesis block")
}
block, err := genesis.Commit(db)
- return genesis.Config, block.Hash(), err
+ if err != nil {
+ return genesis.Config, common.Hash{}, err
+ }
+ return genesis.Config, block.Hash(), nil
}
// We have the genesis block in database(perhaps in ancient database)
@@ -180,7 +183,10 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
return genesis.Config, hash, &GenesisMismatchError{stored, hash}
}
block, err := genesis.Commit(db)
- return genesis.Config, block.Hash(), err
+ if err != nil {
+ return genesis.Config, hash, err
+ }
+ return genesis.Config, block.Hash(), nil
}
// Check whether the genesis block is already written.