kohler/click — pull request #115 by trackpick (2014-04-04 04:43:26+00:00)
Title: Fix bypass traversal

Hi Eddie,

I have another Bypass fix for you! The meat is in the last commit:

When visiting a Bypass element, Locator::visit() sets _port to the port
it wishes to traverse through and then, while visiting the Bypass's
children, checks that it's in the child connected to that port. If it's
in the right child and that child is not a Bypass, it assigns _e and
_port as the final result and attempts to finish the traversal by
returning false.

However, returning false from visit() only ensures that the traversal
doesn't continue through the current element; traversal through the
*parent* Bypass element may not have completed, and it may visit further
siblings. When traversal visits a next sibling, _port has been
clobbered, and so it's possible for Locator::visit() to consider the
sibling when it shouldn't.

This commit fixes the bug by storing the port to check in a separate
variable, _from_port, and using _port to only store the result.

Cheers,
Patrick