From ab1c2fe050a4dd502c863178696a54c44610ca82 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 1 Nov 2024 17:04:24 -0700 Subject: [PATCH] fix: leaking response body upon PromptObject() error --- api-prompt-object.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api-prompt-object.go b/api-prompt-object.go index a4dd6a1b1..dac062a75 100644 --- a/api-prompt-object.go +++ b/api-prompt-object.go @@ -68,10 +68,10 @@ func (c *Client) PromptObject(ctx context.Context, bucketName, objectName, promp if err != nil { return nil, err } - if resp != nil { - if resp.StatusCode != http.StatusOK { - return nil, httpRespToErrorResponse(resp, bucketName, objectName) - } + + if resp.StatusCode != http.StatusOK { + defer closeResponse(resp) + return nil, httpRespToErrorResponse(resp, bucketName, objectName) } return resp.Body, nil