Skip to content

Commit

Permalink
fix: panic when the response is nil
Browse files Browse the repository at this point in the history
This change is copied from btcd@master(718d268) directly
  • Loading branch information
mission-liao authored and losh11 committed Mar 29, 2023
1 parent d6898fb commit 48461b6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions rpcclient/infrastructure.go
Expand Up @@ -809,6 +809,16 @@ func (c *Client) handleSendPostMessage(jReq *jsonRequest) {
jReq.responseChan <- &Response{err: err}
return
}
// We still want to return an error if for any reason the respone
// remains empty.
if httpResponse == nil {
jReq.responseChan <- &Response{
err: fmt.Errorf("invalid http POST response (nil), "+
"method: %s, id: %d, last error=%v",
jReq.method, jReq.id, lastErr),

Check failure on line 818 in rpcclient/infrastructure.go

View workflow job for this annotation

GitHub Actions / Unit race

undefined: lastErr

Check failure on line 818 in rpcclient/infrastructure.go

View workflow job for this annotation

GitHub Actions / Unit race

undefined: lastErr
}
return
}

// Read the raw bytes and close the response.
respBytes, err := ioutil.ReadAll(httpResponse.Body)
Expand Down

0 comments on commit 48461b6

Please sign in to comment.