Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix invalid array index generation in fml.coffee #1312

Merged
merged 1 commit into from Feb 10, 2014

Conversation

Projects
None yet
2 participants
Contributor

kppullin commented Feb 8, 2014

Swapped the usage of Math.round with Math.floor to prevent the generation of an invalid array index and subsequent exception.

Example:

Assume Math.random() returns .9 and the array length is 5.

Math.round(.9 * 5) yields 5, exceeding the bounds of the array and triggers an exception.
Math.floor(.9 * 5) yields 4, a valid index and the script works as expected.

@kppullin kppullin Fix invalid array index generation in fml.coffee
Swapped the usage of `Math.round` with `Math.floor` to prevent the generation of an invalid array index and subsequent exception.


Example:

Assume Math.random() returns `.9` and the array length is 5.

`Math.round(.9 * 5)` yields 5, exceeding the bounds of the array, and triggers an exception.
`Math.floor(.9 * 5)` yields 4, a valid index and the script works as expected.
c44c99a

@technicalpickles technicalpickles added a commit that referenced this pull request Feb 10, 2014

@technicalpickles technicalpickles Merge pull request #1312 from kppullin/patch-1
Fix invalid array index generation in fml.coffee
f78097d

@technicalpickles technicalpickles merged commit f78097d into github:master Feb 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment