[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24444] trunk/blender/source/blender/ editors/mesh/meshtools.c: Fix for [#19847] Joined meshes fail to render

Matt Ebb matt at mke3.net
Tue Nov 10 07:29:11 CET 2009


Revision: 24444
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24444
Author:   broken
Date:     2009-11-10 07:29:10 +0100 (Tue, 10 Nov 2009)

Log Message:
-----------
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

Modified Paths:
--------------
    trunk/blender/source/blender/editors/mesh/meshtools.c

Modified: trunk/blender/source/blender/editors/mesh/meshtools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/meshtools.c	2009-11-10 04:56:55 UTC (rev 24443)
+++ trunk/blender/source/blender/editors/mesh/meshtools.c	2009-11-10 06:29:10 UTC (rev 24444)
@@ -123,7 +123,7 @@
 	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 @@
 	
 	/* 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 @@
 					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 @@
 	ob->totcol= me->totcol= totcol;
 	ob->colbits= 0;
 
-	MEM_freeN(matmap);
+	if (matmap) MEM_freeN(matmap);
 	
 	/* other mesh users */
 	test_object_materials((ID *)me);





More information about the Bf-blender-cvs mailing list