Skip to content

Commit

Permalink
basicnode: don't panic on negative index
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMure authored and rvagg committed Sep 2, 2024
1 parent 40c3462 commit 8bff6c6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions node/basicnode/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 idx < 0 {
return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfInt(idx)}
}
if n.Length() <= idx {
return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfInt(idx)}
}
Expand Down

0 comments on commit 8bff6c6

Please sign in to comment.