diff --git a/source/blender/blenkernel/intern/material.cc b/source/blender/blenkernel/intern/material.cc index 081533da770..f1bdecc2ddb 100644 --- a/source/blender/blenkernel/intern/material.cc +++ b/source/blender/blenkernel/intern/material.cc @@ -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, diff --git a/source/blender/makesrna/intern/rna_material.cc b/source/blender/makesrna/intern/rna_material.cc index 596b1099559..c5286487f0e 100644 --- a/source/blender/makesrna/intern/rna_material.cc +++ b/source/blender/makesrna/intern/rna_material.cc @@ -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) {