protection against out of memory in masks

more potential fix for #9808