diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-04-02 19:27:58 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-04-02 19:27:58 +0800 |
commit | b86450aaae361ef183928b2de53e3724d3e174a8 (patch) | |
tree | 2e22cd47e079f21d4fa21f47e6754a642e76a9b6 | |
parent | e402e1dc2e72df2a433b984caeaba771085b2b66 (diff) | |
download | dexon-b86450aaae361ef183928b2de53e3724d3e174a8.tar dexon-b86450aaae361ef183928b2de53e3724d3e174a8.tar.gz dexon-b86450aaae361ef183928b2de53e3724d3e174a8.tar.bz2 dexon-b86450aaae361ef183928b2de53e3724d3e174a8.tar.lz dexon-b86450aaae361ef183928b2de53e3724d3e174a8.tar.xz dexon-b86450aaae361ef183928b2de53e3724d3e174a8.tar.zst dexon-b86450aaae361ef183928b2de53e3724d3e174a8.zip |
Guard from nil pointers
-rw-r--r-- | rpc/api.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/rpc/api.go b/rpc/api.go index 478ca8752..20299bef1 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -238,6 +238,10 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err } br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash), false) + if br == nil { + *reply = nil + return nil + } if args.Index >= int64(len(br.Uncles)) || args.Index < 0 { return NewValidationError("Index", "does not exist") @@ -256,6 +260,11 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err block := api.xeth().EthBlockByNumber(args.BlockNumber) v := NewBlockRes(block, true) + if v == nil { + *reply = nil + return nil + } + if args.Index >= int64(len(v.Uncles)) || args.Index < 0 { return NewValidationError("Index", "does not exist") } |