From b86450aaae361ef183928b2de53e3724d3e174a8 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 2 Apr 2015 13:27:58 +0200 Subject: Guard from nil pointers --- rpc/api.go | 9 +++++++++ 1 file changed, 9 insertions(+) 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") } -- cgit