diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-12-27 14:18:37 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-12-27 14:18:37 +0300 |
commit | 097b9019ceea7e0c9ef399b548dc917b8525c02e (patch) | |
tree | 66fb17b32f541250cb5b1b35ca87ce0c3aa8e389 /source/blender | |
parent | 6de8ff579695f7c831684f1355ff4b1f9494a32b (diff) |
Fix T59799: texture paint mode crash for object with no materials.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/modes/paint_texture_mode.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c index cf6f32170f1..a89616c2cae 100644 --- a/source/blender/draw/modes/paint_texture_mode.c +++ b/source/blender/draw/modes/paint_texture_mode.c @@ -191,12 +191,13 @@ static void PAINT_TEXTURE_cache_init(void *vedata) Scene *scene = draw_ctx->scene; const bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL); const Mesh *me = ob->data; + const int mat_nr = max_ii(1, me->totcol); stl->g_data->shgroup_image_array = MEM_mallocN( - sizeof(*stl->g_data->shgroup_image_array) * (use_material_slots ? me->totcol : 1), __func__); + sizeof(*stl->g_data->shgroup_image_array) * (use_material_slots ? mat_nr : 1), __func__); if (use_material_slots) { - for (int i = 0; i < me->totcol; i++) { + for (int i = 0; i < mat_nr; i++) { Material *ma = give_current_material(ob, i + 1); Image *ima = (ma && ma->texpaintslot) ? ma->texpaintslot[ma->paint_active_slot].ima : NULL; GPUTexture *tex = ima ? |