From d17c3f4407fd2d58b2b906eb83d738ad4e63048c Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 14 Sep 2015 17:30:42 -0400 Subject: [PATCH] Fix body closing in List method --- api/logical.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/logical.go b/api/logical.go index 323f4058b..20fe13fca 100644 --- a/api/logical.go +++ b/api/logical.go @@ -29,13 +29,15 @@ func (c *Logical) Read(path string) (*Secret, error) { func (c *Logical) List(path string) (*Secret, error) { r := c.c.NewRequest("LIST", "/v1/"+path) resp, err := c.c.RawRequest(r) + if resp != nil { + defer resp.Body.Close() + } if resp != nil && resp.StatusCode == 404 { return nil, nil } if err != nil { return nil, err } - defer resp.Body.Close() return ParseSecret(resp.Body) }