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

Remove OmitEmpty; fix nil pointer dereference #351

Merged
merged 2 commits into from
Jul 10, 2024

Conversation

egibs
Copy link
Member

@egibs egibs commented Jul 10, 2024

Closes: #348

This PR removes the [unused] --omit-empty flag.

Additionally, since we're now returning nil when only len(fr.Behaviors) is 0, the ordering of if fr.Error != "" { ... } before if fr == nil { ... } was causing a nil pointer dereference so I fixed that as well.

@egibs egibs requested a review from tstromberg July 10, 2024 14:55
@egibs
Copy link
Member Author

egibs commented Jul 10, 2024

Looking into this again:

--- FAIL: TestDiff/macOS/clean/ls.sdiff.level_2 (0.05s)
        samples_test.go:232: simple diff output mismatch: (-want +got):
              (
              	"""
            - 	*** changed: macOS/clean/ls
            + 	--- missing: .
              	-process/name/set
              	"""
              )

if len(fr.Behaviors) == 0 && c.OmitEmpty {
return nil, nil
if len(fr.Behaviors) == 0 {
return &bincapz.FileReport{Path: path}, nil
Copy link
Member Author

Choose a reason for hiding this comment

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

Without this, rel, err := filepath.Rel(fromPath, f.Path) results in ..

@egibs egibs merged commit 7a1a734 into chainguard-dev:main Jul 10, 2024
6 checks passed
@egibs egibs deleted the remove-omit-empty branch July 19, 2024 13:20
egibs added a commit to egibs/malcontent that referenced this pull request Aug 5, 2024
* Remove OmitEmpty; fix nil pointer dereference

Signed-off-by: egibs <[email protected]>

* Prevent . being reported for rel path

Signed-off-by: egibs <[email protected]>

---------

Signed-off-by: egibs <[email protected]>
egibs added a commit to egibs/malcontent that referenced this pull request Sep 25, 2024
* Remove OmitEmpty; fix nil pointer dereference

Signed-off-by: egibs <[email protected]>

* Prevent . being reported for rel path

Signed-off-by: egibs <[email protected]>

---------

Signed-off-by: egibs <[email protected]>
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.

Remove unused --omit-empty flag
2 participants