Skip to content
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

Fix panic when k.begin() attempts to return early #32

Merged
merged 2 commits into from
Apr 22, 2020

Conversation

dnesting
Copy link
Contributor

@dnesting dnesting commented Apr 22, 2020

https://github.com/go-piv/piv-go/blob/master/piv/key.go#L537-L541

The defer calls tx.Close() when needed to clean up, however all of the early return paths explicitly return nil for tx, causing a nil dereference panic. This PR has two commits, one with the test case proving the panic and the other with a fix.

Another approach could be setting err = fmt.Errorf(...) and just doing a bare return at the end.

@ericchiang ericchiang merged commit e45902f into go-piv:master Apr 22, 2020
@ericchiang
Copy link
Collaborator

Thanks!

@dnesting dnesting deleted the crash branch April 22, 2020 12:14
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.

None yet

2 participants