Related to T56363, this is not fixing the root of the bug, but ID
copying should always be a good occasion to ensure sanity of our data
(and error checking is always better than a crash!).
ob_dst->matbits = MEM_dupallocN(ob_src->matbits);
ob_dst->totcol = ob_src->totcol;
}
ob_dst->matbits = MEM_dupallocN(ob_src->matbits);
ob_dst->totcol = ob_src->totcol;
}
+ else if (ob_dst->mat != NULL || ob_dst->matbits != NULL) {
+ /* This shall not be needed, but better be safe than sorry. */
+ BLI_assert(!"Object copy: non-NULL material pointers with zero counter, should not happen.");
+ ob_dst->mat = NULL;
+ ob_dst->matbits = NULL;
+ }
if (ob_src->iuser) ob_dst->iuser = MEM_dupallocN(ob_src->iuser);
if (ob_src->iuser) ob_dst->iuser = MEM_dupallocN(ob_src->iuser);