Skip to content

Commit 8485f7c

Browse files
authored
Merge pull request #19854 from karalabe/genesis-commit-check
core: check error before accessing potentially nil block
2 parents f088c65 + 61a20cb commit 8485f7c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

core/genesis.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
164164
log.Info("Writing custom genesis block")
165165
}
166166
block, err := genesis.Commit(db)
167-
return genesis.Config, block.Hash(), err
167+
if err != nil {
168+
return genesis.Config, common.Hash{}, err
169+
}
170+
return genesis.Config, block.Hash(), nil
168171
}
169172

170173
// We have the genesis block in database(perhaps in ancient database)
@@ -180,7 +183,10 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
180183
return genesis.Config, hash, &GenesisMismatchError{stored, hash}
181184
}
182185
block, err := genesis.Commit(db)
183-
return genesis.Config, block.Hash(), err
186+
if err != nil {
187+
return genesis.Config, hash, err
188+
}
189+
return genesis.Config, block.Hash(), nil
184190
}
185191

186192
// Check whether the genesis block is already written.

0 commit comments

Comments
 (0)