diff options
author | Matt Ebb <matt@mke3.net> | 2009-11-10 09:29:10 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2009-11-10 09:29:10 +0300 |
commit | 4573120399b5888c640edff8b6a9eadf91662396 (patch) | |
tree | 879935a9f96dbac3fccd7d1ac6d4a14e4139ddd1 /source | |
parent | 297045fd965d506b3475ae8897e217a3351929e4 (diff) |
Fix for [#19847] Joined meshes fail to render
Join function was accessing invalid memory for material indices when no materials were originally present on the joining objects
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/mesh/meshtools.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 8bd8629a595..18125207eca 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -123,7 +123,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) KeyBlock *kb, *okb, *kbn; float imat[4][4], cmat[4][4], *fp1, *fp2, curpos; int a, b, totcol, totmat=0, totedge=0, totvert=0, totface=0, ok=0; - int vertofs, *matmap; + int vertofs, *matmap=NULL; int i, j, index, haskey=0, edgeofs, faceofs; bDeformGroup *dg, *odg; MDeformVert *dvert; @@ -168,7 +168,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* new material indices and material array */ matar= MEM_callocN(sizeof(void*)*totmat, "join_mesh matar"); - matmap= MEM_callocN(sizeof(int)*totmat, "join_mesh matmap"); + if (totmat) matmap= MEM_callocN(sizeof(int)*totmat, "join_mesh matmap"); totcol= ob->totcol; /* obact materials in new main array, is nicer start! */ @@ -435,7 +435,10 @@ int join_mesh_exec(bContext *C, wmOperator *op) mface->v3+= vertofs; if(mface->v4) mface->v4+= vertofs; - mface->mat_nr= matmap[(int)mface->mat_nr]; + if (matmap) + mface->mat_nr= matmap[(int)mface->mat_nr]; + else + mface->mat_nr= 0; } faceofs += me->totface; @@ -508,7 +511,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) ob->totcol= me->totcol= totcol; ob->colbits= 0; - MEM_freeN(matmap); + if (matmap) MEM_freeN(matmap); /* other mesh users */ test_object_materials((ID *)me); |