Skip to content

Commit

Permalink
http.go: close form file if copyZeroAlloc fails (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear authored Mar 3, 2023
1 parent 8800d4b commit 4e8c92b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ func WriteMultipartForm(w io.Writer, f *multipart.Form, boundary string) error {
return fmt.Errorf("cannot open form file %q (%q): %w", k, fv.Filename, err)
}
if _, err = copyZeroAlloc(vw, fh); err != nil {
_ = fh.Close()
return fmt.Errorf("error when copying form file %q (%q): %w", k, fv.Filename, err)
}
if err = fh.Close(); err != nil {
Expand Down

0 comments on commit 4e8c92b

Please sign in to comment.