From 84b8aaf24f9aa6ff6aa3d8a0a59418460762dea7 Mon Sep 17 00:00:00 2001 From: lukesolo Date: Sat, 29 Feb 2020 17:46:25 +0200 Subject: [PATCH] Fix panic in FormFile if file not found (#1515) --- context.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/context.go b/context.go index 86b50646..dfcbe16c 100644 --- a/context.go +++ b/context.go @@ -360,8 +360,11 @@ func (c *context) FormParams() (url.Values, error) { func (c *context) FormFile(name string) (*multipart.FileHeader, error) { f, fh, err := c.request.FormFile(name) + if err != nil { + return nil, err + } defer f.Close() - return fh, err + return fh, nil } func (c *context) MultipartForm() (*multipart.Form, error) {