Skip to content

Conversation

@vonovak
Copy link
Contributor

@vonovak vonovak commented Mar 1, 2019

SectionList accesses items outside of the array bounds.

This was discovered when using mobx, which warns you: [mobx.array] Attempt to read an array index (${index}) that is out of bounds. This is because section.data[itemIndex + 1] goes beyond array length.

This PR adds an array length check and simplifies the code a bit to avoid repetitive this.props.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 1, 2019
@vonovak vonovak changed the title make sure to check array bounds make sure to check array bounds in VirtualizedSectionList.js Mar 1, 2019
@vonovak vonovak changed the title make sure to check array bounds in VirtualizedSectionList.js make sure to check array bounds in VirtualizedSectionList Mar 1, 2019
Copy link

@analysis-bot analysis-bot left a comment

Choose a reason for hiding this comment

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

Code analysis results:

  • eslint found some issues. Run yarn lint --fix to automatically fix problems.

@pull-bot
Copy link

pull-bot commented Mar 1, 2019

Messages
📖 📋 Missing Summary - Can you add a Summary? To do so, add a "## Summary" section to your PR description. This is a good place to explain the motivation for making this change.
📖 📋 Missing Test Plan - Can you add a Test Plan? To do so, add a "## Test Plan" section to your PR description. A Test Plan lets us know how these changes were tested.
📖

📋 Missing Changelog - Can you add a Changelog? To do so, add a "## Changelog" section to your PR description. A changelog entry has the following format: [CATEGORY] [TYPE] - Message.

Generated by 🚫 dangerJS against dcf8519

@vonovak vonovak force-pushed the checkArrayBounds branch from 6c6fb78 to dcf8519 Compare March 3, 2019 20:59
Copy link
Contributor

@cpojer cpojer left a comment

Choose a reason for hiding this comment

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

Thanks!

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Mar 4, 2019
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @vonovak in 929908f.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added Merged This PR has been merged. and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Mar 4, 2019
grabbou pushed a commit that referenced this pull request May 6, 2019
Summary:
SectionList accesses items outside of the array bounds.

This was discovered when using mobx, which warns you: `[mobx.array] Attempt to read an array index (${index}) that is out of bounds`. This is because `section.data[itemIndex + 1]` goes beyond array length.

This PR adds an array length check and simplifies the code a bit to avoid repetitive `this.props.`
Pull Request resolved: #23710

Differential Revision: D14298557

Pulled By: cpojer

fbshipit-source-id: fee3422ad5b053d91a097c5842f46e78a149c3d5
@vonovak vonovak deleted the checkArrayBounds branch May 13, 2019 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Component: SectionList Merged This PR has been merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants