nicolasgramlich/AndEngine — pull request #114 by player-03 (2012-05-24 02:08:41+00:00)
Title: Fixed a game-crashing exception

The Entity.onManagedUpdate() method caches the size of its mChildren array before iterating through it and updating its children. There are multiple valid reasons for these children to remove themselves during their update. However, if one does, its parent will iterate out of bounds, because its mChildren array will be shorter than the cached value says it is.

This change removes the cached value and instead has the loop recheck the array's size on every iteration. Yes, this is slightly slower, but given the nature of this loop, it doesn't make sense to rely on the array staying the same length.

See http://www.andengine.org/forums/gles2/removing-an-entity-when-a-modifier-finishes-t7999.html for a more in-depth discussion.