From 279afd7947cb915073cddc78bd21eddeb6677910 Mon Sep 17 00:00:00 2001 From: Jakub Freebit <49676311+jakub-freebit@users.noreply.github.com> Date: Wed, 31 Aug 2022 19:31:16 +0900 Subject: [PATCH] mobile: close node on error (#25643) --- mobile/geth.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mobile/geth.go b/mobile/geth.go index 709b68cbd..204e29c8b 100644 --- a/mobile/geth.go +++ b/mobile/geth.go @@ -156,6 +156,7 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) { // Parse the user supplied genesis spec if not mainnet genesis = new(core.Genesis) if err := json.Unmarshal([]byte(config.EthereumGenesis), genesis); err != nil { + rawStack.Close() return nil, fmt.Errorf("invalid genesis spec: %v", err) } // If we have the Ropsten testnet, hard code the chain configs too @@ -196,11 +197,13 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) { ethConf.DatabaseCache = config.EthereumDatabaseCache lesBackend, err := les.New(rawStack, ðConf) if err != nil { + rawStack.Close() return nil, fmt.Errorf("ethereum init: %v", err) } // If netstats reporting is requested, do it if config.EthereumNetStats != "" { if err := ethstats.New(rawStack, lesBackend.ApiBackend, lesBackend.Engine(), config.EthereumNetStats); err != nil { + rawStack.Close() return nil, fmt.Errorf("netstats init: %v", err) } }