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
Notes: blender-bot 2023-02-14 10:55:42 +01:00
Referenced by issue #39351, Blender 2.70 - Blender crashes when enabling Mesh Analysis
1 changed files with 5 additions and 6 deletions

View File

@ -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);
}
}
}