masks: quick fix for #9833

I still need to reconsider the logics and right places for buffer allocation