Right - there's an issue here with ownership of the 'pattern' c-string. I suggest making this const char *, so the MCPatternMatcher class and descendents don't own it, and are just borrowing it from the caller (this works with the change to make 'matcher' in MCFilter to not be an instance-var).