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 crash and provide better error when chip is wrong. #559

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

floitsch
Copy link
Member

Fixes #558

@floitsch floitsch requested a review from kasperl September 23, 2024 15:09
Comment on lines -44 to +59
defer bundle.Close()
if err != nil {
return err
}

defer bundle.Close()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh.. this seems unrelated, right?

Also (I'm not an expert at golang so please correct me) can deferring after the err != nil check lead to bundle not being closed because in case of an error the program will return before the defer is set?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thinking is that if err == nil, then bundle will be nil or at least not open. If bundle is nil, then calling bundle.Close (even deferred) will cause a crash.

Copy link
Member

@kasperl kasperl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Comment on lines -44 to +59
defer bundle.Close()
if err != nil {
return err
}

defer bundle.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thinking is that if err == nil, then bundle will be nil or at least not open. If bundle is nil, then calling bundle.Close (even deferred) will cause a crash.

@floitsch floitsch merged commit 905c786 into main Sep 24, 2024
7 checks passed
@floitsch floitsch deleted the floitsch/harden-no-chip branch September 24, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Crash when an envelope can't be found
3 participants