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

jsonblob: check for error in Next #1181

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libvuln/jsonblob/jsonblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
}
}
}
if l.Err() != nil {
Copy link
Contributor Author

@RTann RTann Dec 14, 2023

Choose a reason for hiding this comment

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

this may not be completely correct. This allows EOF to still return true which is probably ok, but only if l.next != nil, I think. When l.next = nil and l.err == io.EOF, this returns true, but will still cause a panic because l.e will, therefore, be nil, which is never expected when Next returns true

Copy link
Member

Choose a reason for hiding this comment

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

By my thinking, the error check on the first entry should catch this?

return false
}

Check warning on line 108 in libvuln/jsonblob/jsonblob.go

View check run for this annotation

Codecov / codecov/patch

libvuln/jsonblob/jsonblob.go#L107-L108

Added lines #L107 - L108 were not covered by tests
l.e = l.next
return true
}
Expand Down