Fixes potential memory read issue with mask and mapping array