Skip to content

Conversation

@bifurcation
Copy link

@bifurcation bifurcation commented Mar 15, 2025

The logic here allows situations where the access to state.objects will be out of bounds. This PR just makes the obvious fix to keep state.index in-bounds.

{
let state = self.state.lock();
if self.index < state.objects.len() {
if self.index < state.objects.len() - 1 {

Choose a reason for hiding this comment

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

I believe rearranging the inequality like if self.index + 1 < state.objects.len() { could be safer in most cases, considering that state.objects.len() can return 0.

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.

2 participants