diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-11-06 18:06:57 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-11-06 18:08:10 +0300 |
commit | 65b414cfb291e8ae47e92ab1b101de3fa6d19704 (patch) | |
tree | 0dba19d81152b9cc5993ec280a0e0f5433f0162e | |
parent | 3a65ea3b2d62235fdabf9eeeade675e2b1e338aa (diff) |
Fix T71319, T71015: crash in edit mode with out of range material assignments
-rw-r--r-- | source/blender/draw/intern/draw_cache_extract_mesh.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index fb439016a87..c30cf9f6328 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -484,7 +484,7 @@ static void *extract_tris_init(const MeshRenderData *mr, void *UNUSED(ibo)) return data; } -static void extract_tris_looptri_bmesh(const MeshRenderData *UNUSED(mr), +static void extract_tris_looptri_bmesh(const MeshRenderData *mr, int UNUSED(t), BMLoop **elt, void *_data) @@ -492,8 +492,9 @@ static void extract_tris_looptri_bmesh(const MeshRenderData *UNUSED(mr), if (!BM_elem_flag_test(elt[0]->f, BM_ELEM_HIDDEN)) { MeshExtract_Tri_Data *data = _data; int *mat_tri_ofs = data->tri_mat_end; + int mat = min_ii(elt[0]->f->mat_nr, mr->mat_len - 1); GPU_indexbuf_set_tri_verts(&data->elb, - mat_tri_ofs[elt[0]->f->mat_nr]++, + mat_tri_ofs[mat]++, BM_elem_index_get(elt[0]), BM_elem_index_get(elt[1]), BM_elem_index_get(elt[2])); |