savi-lang / savi

A fast language for programmers who are passionate about their craft.
BSD 3-Clause "New" or "Revised" License
154 stars 12 forks source link

Fix memory safety of `each`-style iteration methods. #422

Closed jemc closed 1 year ago

jemc commented 1 year ago

Prior to this commit, these yielding methods were vulnerable to memory unsafety issues if the length of the iterated collection got reduced by something the caller did inside of the yield block.

This commit fixes these issues to make sure the internal loop iterations are always bounded to the current _size of the collection.