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!
This commit is contained in:
Lukas Tönne 2014-03-23 11:35:52 +01:00
parent 4c73001093
commit 58c22d8fe8

@ -1744,10 +1744,8 @@ static void statvis_calc_overhang(
bool is_max; bool is_max;
/* fallback */ /* fallback */
const char col_fallback[2][4] = { unsigned char col_fallback[4] = {64, 64, 64, 255}; /* gray */
{64, 64, 64, 255}, /* gray */ unsigned char col_fallback_max[4] = {0, 0, 0, 255}; /* max color */
{0, 0, 0, 255}, /* max color */
};
BLI_assert(min <= max); BLI_assert(min <= max);
@ -1762,7 +1760,7 @@ static void statvis_calc_overhang(
{ {
float fcol[3]; float fcol[3];
weight_to_rgb(fcol, 1.0f); 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 */ /* now convert into global space */
@ -1779,7 +1777,8 @@ static void statvis_calc_overhang(
rgb_float_to_uchar(r_face_colors[index], fcol); rgb_float_to_uchar(r_face_colors[index], fcol);
} }
else { 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);
} }
} }
} }