mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00:00
net/http: multipart ReadForm close file after copy
Always close the file regardless of whether the copy succeeds or fails. Pass along the close error if the copy succeeds Fixes #16296 Change-Id: Ib394655b91d25750f029f17b3846d985f673fb50 Reviewed-on: https://go-review.googlesource.com/30410 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
f69991c17d
commit
7478ea5dba
1 changed files with 3 additions and 1 deletions
|
@ -79,8 +79,10 @@ func (r *Reader) readForm(maxMemory int64) (_ *Form, err error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
_, err = io.Copy(file, io.MultiReader(&b, p))
|
||||
if cerr := file.Close(); err == nil {
|
||||
err = cerr
|
||||
}
|
||||
if err != nil {
|
||||
os.Remove(file.Name())
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue