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

basicnode: don't panic on negative index #571

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

MichaelMure
Copy link
Contributor

I'm not too sure what error should be returned, but it's certainly better than a panic().

@@ -31,6 +31,9 @@ func (plainList) LookupByNode(datamodel.Node) (datamodel.Node, error) {
return mixins.List{TypeName: "list"}.LookupByNode(nil)
}
func (n *plainList) LookupByIndex(idx int64) (datamodel.Node, error) {
if n.Length() < 0 {
Copy link
Member

Choose a reason for hiding this comment

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

do you want if the length is less than 0 here, or if idx < 0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oof of course, fixed it

@rvagg rvagg merged commit 8bff6c6 into ipld:master Sep 2, 2024
11 checks passed
MichaelMure added a commit to ucan-wg/go-ucan that referenced this pull request Sep 2, 2024
@MichaelMure MichaelMure deleted the panic-list branch September 2, 2024 16:12
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