Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit e97cd4a

Browse files
author
Evan Phoenix
authored
Merge pull request #4727 from hashicorp/b-dont-leak-body
Close the resp.Body in all exits of the loop body
2 parents 0bcdac2 + 16c7510 commit e97cd4a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: builtin/tfc/config_sourcer.go

+5
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ func (cs *ConfigSourcer) read(
242242
Error: status.New(codes.Aborted, "failed to read workspace info").Proto(),
243243
}
244244

245+
resp.Body.Close()
245246
continue
246247
}
247248

@@ -255,6 +256,7 @@ func (cs *ConfigSourcer) read(
255256
Error: status.New(codes.Aborted, err.Error()).Proto(),
256257
}
257258

259+
resp.Body.Close()
258260
continue
259261
}
260262

@@ -305,12 +307,14 @@ func (cs *ConfigSourcer) read(
305307

306308
continue
307309
}
310+
308311
if resp.StatusCode != 200 {
309312
L.Error("error in sending request for state version for workspace, unexpected response code", "workspace_id", id, "code", resp.Status)
310313
result.Result = &pb.ConfigSource_Value_Error{
311314
Error: status.New(codes.Aborted, err.Error()).Proto(),
312315
}
313316

317+
resp.Body.Close()
314318
continue
315319
}
316320

@@ -324,6 +328,7 @@ func (cs *ConfigSourcer) read(
324328
Error: status.New(codes.Aborted, err.Error()).Proto(),
325329
}
326330

331+
resp.Body.Close()
327332
continue
328333
}
329334

0 commit comments

Comments
 (0)