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 null pointer deref in diff if no Upstream #3549

Merged
merged 2 commits into from
Sep 9, 2022

Conversation

Ralph7C2
Copy link
Contributor

@Ralph7C2 Ralph7C2 commented Sep 9, 2022

Running kpt pkg diff without an upstream set panics because we attempt
to dereference kptFile.Upstream without checking to see if it is nil.

This commit adds a check and returns early if necessary.

Running `kpt pkg diff` without an upstream set panics because we attempt
to dereference `kptFile.Upstream` without checking to see if it is nil.
This commit adds a check and returns early if necessary.
Copy link
Contributor

@natasha41575 natasha41575 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! I can reproduce the error on the main branch and I agree an error message is far better than panicking.

internal/util/diff/diff.go Outdated Show resolved Hide resolved
Co-authored-by: Natasha Sarkar <natashasarkar@google.com>
Copy link
Contributor

@natasha41575 natasha41575 left a comment

Choose a reason for hiding this comment

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

LGTM (and built kpt from this PR to verify the fix). Will defer to @mortent or @droot (or another code owner) to give their final approval and merge.

@droot
Copy link
Contributor

droot commented Sep 9, 2022

Awesome! Merging this in.. Thanks.

@droot droot merged commit c6adbb3 into kptdev:main Sep 9, 2022
@Ralph7C2 Ralph7C2 deleted the rl/diff-npe branch September 9, 2022 20:04
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.

3 participants