Skip to content

Commit

Permalink
Fix possible nil pointer dereference in event-dispatcher (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
creydr authored Jun 12, 2024
1 parent 471dd0a commit 3894539
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/kncloudevents/event_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (d *Dispatcher) executeRequest(ctx context.Context, target duckv1.Addressab
if isFailure(response.StatusCode) {
// Read response body into dispatchInfo for failures
if readErr != nil && readErr != io.EOF {
dispatchInfo.ResponseBody = []byte(fmt.Sprintf("dispatch resulted in status \"%s\". Could not read response body: error: %s", response.Status, err.Error()))
dispatchInfo.ResponseBody = []byte(fmt.Sprintf("dispatch resulted in status \"%s\". Could not read response body: error: %s", response.Status, readErr.Error()))
} else {
dispatchInfo.ResponseBody = body.Bytes()
}
Expand All @@ -315,7 +315,7 @@ func (d *Dispatcher) executeRequest(ctx context.Context, target duckv1.Addressab

var responseMessageBody []byte
if readErr != nil && readErr != io.EOF {
responseMessageBody = []byte(fmt.Sprintf("Failed to read response body: %s", err.Error()))
responseMessageBody = []byte(fmt.Sprintf("Failed to read response body: %s", readErr.Error()))
} else {
responseMessageBody = body.Bytes()
dispatchInfo.ResponseBody = responseMessageBody
Expand Down

0 comments on commit 3894539

Please sign in to comment.