Fix #116325: crash assigning non-valid material.paint_active_slot #116345

Merged
Philipp Oeser merged 1 commits from lichtwerk/blender:116325 into main 2023-12-19 15:46:14 +01:00
2 changed files with 9 additions and 1 deletions

View File

@ -1638,6 +1638,14 @@ static bool texpaint_slot_node_find_cb(bNode *node, void *userdata)
bNode *BKE_texpaint_slot_material_find_node(Material *ma, short texpaint_slot)
{
if (ma->texpaintslot == nullptr) {
return nullptr;
}
if (texpaint_slot >= ma->tot_slots) {
return nullptr;
}
TexPaintSlot *slot = &ma->texpaintslot[texpaint_slot];
FindTexPaintNodeData find_data = {slot, nullptr};
ntree_foreach_texnode_recursive(ma->nodetree,

View File

@ -163,7 +163,7 @@ static void rna_Material_active_paint_texture_index_update(bContext *C, PointerR
}
}
if (ma->texpaintslot) {
if (ma->texpaintslot && (ma->tot_slots > ma->paint_active_slot)) {
TexPaintSlot *slot = &ma->texpaintslot[ma->paint_active_slot];
Image *image = slot->ima;
if (image) {