fix segfault on UVRASTER layers with mask set (#4779)
avoid segfault on erroneous mask references (#4779)