Fix A layer using a mask and a label with repeatdistance can crash (#4764)