Skip to content

Fix panic in FormFile if file not found #1515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 29, 2020
Merged

Fix panic in FormFile if file not found #1515

merged 1 commit into from
Feb 29, 2020

Conversation

lukesolo
Copy link

@lukesolo lukesolo commented Feb 27, 2020

func (c *context) FormFile(name string) (*multipart.FileHeader, error) {
	f, fh, err := c.request.FormFile(name)
	defer f.Close()
	return fh, err
}

f.Close() panics with nil pointer exception if error wasn't checked.

@codecov
Copy link

codecov bot commented Feb 27, 2020

Codecov Report

Merging #1515 into master will decrease coverage by 0.07%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1515      +/-   ##
==========================================
- Coverage   84.91%   84.83%   -0.08%     
==========================================
  Files          28       28              
  Lines        2161     2163       +2     
==========================================
  Hits         1835     1835              
- Misses        212      213       +1     
- Partials      114      115       +1
Impacted Files Coverage Δ
context.go 89.72% <33.33%> (-0.72%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c5af01...f22d0b1. Read the comment docs.

@vishr vishr merged commit 84b8aaf into labstack:master Feb 29, 2020
@lukesolo lukesolo deleted the fix-panic-in-form-file branch February 29, 2020 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants