fix invalid memory address or nil pointer dereference

This commit is contained in:
Anton Kaliaev 2017-05-26 16:56:44 +02:00 committed by Ethan Buchman
parent 60a1f49a5c
commit 6c1572c9b8
1 changed files with 2 additions and 3 deletions

View File

@ -146,9 +146,8 @@ func unmarshalResponseBytes(responseBytes []byte, result interface{}) (interface
if err != nil { if err != nil {
return nil, errors.Errorf("Error unmarshalling rpc response: %v", err) return nil, errors.Errorf("Error unmarshalling rpc response: %v", err)
} }
errorStr := response.Error.Message if response.Error != nil && response.Error.Message != "" {
if errorStr != "" { return nil, errors.Errorf("Response error: %v", response.Error.Message)
return nil, errors.Errorf("Response error: %v", errorStr)
} }
// unmarshal the RawMessage into the result // unmarshal the RawMessage into the result
err = json.Unmarshal(*response.Result, result) err = json.Unmarshal(*response.Result, result)