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

Problem: worker exits from a panic when slice bounds out of range #1180

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 7 additions & 0 deletions memiavl/layout_little_endian.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@

func (nodes Nodes) Node(i uint32) NodeLayout {
offset := int(i) * SizeNode
if offset > len(nodes.data) {
return NodeLayout{data: &[SizeNode]byte{}}
}

Check warning on line 23 in memiavl/layout_little_endian.go

View check run for this annotation

Codecov / codecov/patch

memiavl/layout_little_endian.go#L22-L23

Added lines #L22 - L23 were not covered by tests

if offset+SizeNode > len(nodes.data) {
return NodeLayout{data: (*[SizeNode]byte)(nodes.data[offset:])}
}

Check warning on line 27 in memiavl/layout_little_endian.go

View check run for this annotation

Codecov / codecov/patch

memiavl/layout_little_endian.go#L26-L27

Added lines #L26 - L27 were not covered by tests
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should investigate why the caller pass an invalid index, rather than translate the error into a more obscure issue.

return NodeLayout{data: (*[SizeNode]byte)(nodes.data[offset : offset+SizeNode])}
}

Expand Down
Loading