[Bf-blender-cvs] [58c22d8] master: Fix T39351: Blender crashes when enabling Mesh Analysis.

Lukas Tönne noreply at git.blender.org
Sun Mar 23 11:42:28 CET 2014


Commit: 58c22d8fe8d0399ecb137f0984b6fdb45fd57601
Author: Lukas Tönne
Date:   Sun Mar 23 11:35:52 2014 +0100
https://developer.blender.org/rB58c22d8fe8d0399ecb137f0984b6fdb45fd57601

Fix T39351: Blender crashes when enabling Mesh Analysis.

This code was using a //const// char array for fallback colors and then
writing to it (hidden to the compiler by explicit casting). Bad!

===================================================================

M	source/blender/blenkernel/intern/editderivedmesh.c

===================================================================

diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index 913edba..93f7367 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -1744,10 +1744,8 @@ static void statvis_calc_overhang(
 	bool is_max;
 
 	/* fallback */
-	const char col_fallback[2][4] = {
-	    {64, 64, 64, 255},  /* gray */
-	    {0,  0,  0,  255},  /* max color */
-	};
+	unsigned char col_fallback[4] = {64, 64, 64, 255}; /* gray */
+	unsigned char col_fallback_max[4] = {0,  0,  0,  255}; /* max color */
 
 	BLI_assert(min <= max);
 
@@ -1762,7 +1760,7 @@ static void statvis_calc_overhang(
 	{
 		float fcol[3];
 		weight_to_rgb(fcol, 1.0f);
-		rgb_float_to_uchar((unsigned char *)col_fallback[1], fcol);
+		rgb_float_to_uchar(col_fallback_max, fcol);
 	}
 
 	/* now convert into global space */
@@ -1779,7 +1777,8 @@ static void statvis_calc_overhang(
 			rgb_float_to_uchar(r_face_colors[index], fcol);
 		}
 		else {
-			copy_v4_v4_char((char *)r_face_colors[index], (const char *)(col_fallback[is_max]));
+			unsigned char *fallback = is_max ? col_fallback_max : col_fallback;
+			copy_v4_v4_char((char *)r_face_colors[index], (const char *)fallback);
 		}
 	}
 }




More information about the Bf-blender-cvs mailing list