Skip to content

Commit 02b6e7e

Browse files
committed
fix: Fix memory leak in the webhook service
Signed-off-by: Ragnar Paide <[email protected]>
1 parent 8cb0e74 commit 02b6e7e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/services/webhook.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,18 @@ func (s webhookService) Send(notification Notification, dest Destination) error
123123
if err != nil {
124124
return err
125125
}
126+
defer resp.Body.Close()
126127

127128
if !(resp.StatusCode >= 200 && resp.StatusCode <= 299) {
128129
data, err := io.ReadAll(resp.Body)
129130
if err != nil {
130131
data = []byte(fmt.Sprintf("unable to read response data: %v", err))
131132
}
132133
return fmt.Errorf("request to %s has failed with error code %d : %s", request, resp.StatusCode, string(data))
134+
} else {
135+
_, _ = io.Copy(io.Discard, resp.Body)
133136
}
137+
134138
return nil
135139
}
136140

0 commit comments

Comments
 (0)