pk-hack / CoilSnake

https://pk-hack.github.io/CoilSnake/
GNU General Public License v3.0
162 stars 37 forks source link

Fix possible hash collision in doors module #275

Closed tolmar closed 1 year ago

tolmar commented 1 year ago

Yes I actually hit a hash collision. Yay me.

Thanks phoenixbound for identifying this actually was a hash collision.

Testing: I just recompiled a project with this change, and went through a few doors.

charasyn commented 1 year ago

Just to be clear, the bug is that we are using the hash collision as the key in the dictionary. This shouldn't be done, since if we have a hash collision then the two keys will compare equal (since the hash is the key).

When we use the block itself as the key, this is avoided since although the two blocks have the same hash, they will not compare equal, so destination_block in destination_locations will be false and we won't incorrectly overwrite the collided-with door entry.