Skip to content

Fix index out of range panic when passing empty slice to NewIDSelectorBatch and NewIDSelectorBitmap - #72

Open
jizhuozhi wants to merge 1 commit into
blevesearch:masterfrom
jizhuozhi:master
Open

Fix index out of range panic when passing empty slice to NewIDSelectorBatch and NewIDSelectorBitmap#72
jizhuozhi wants to merge 1 commit into
blevesearch:masterfrom
jizhuozhi:master

Conversation

@jizhuozhi

Copy link
Copy Markdown
  • Currently, NewIDSelectorBatch and NewIDSelectorBitmap use &indices[0] / &bitmap[0]
    to obtain the underlying data pointer for the C API call, but this panics with
    index out of range [0] with length 0 when an empty slice is passed.
  • This PR adds a nil-check: when the slice length is 0, a nil pointer is passed to the C layer
    instead of attempting to take the address of the first element.

Avoid index out of range panic when an empty slice is passed.
Pass nil pointer to C layer when len is 0 instead of accessing
indices[0] or bitmap[0] which would panic.
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.

1 participant