Incorrectly accessing the menu pointer, set it to NULL before doing the tests. We don't restore the menu pointer because it is invalid by the time the operator ends.