masks: avoid double-free in expose; should fix #9726