diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-03-23 14:35:52 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2014-03-23 14:37:04 +0400 |
commit | 58c22d8fe8d0399ecb137f0984b6fdb45fd57601 (patch) | |
tree | 71af64ec788a1f15985cd376173815b41d0884ca /source/blender/blenkernel/intern/editderivedmesh.c | |
parent | 4c73001093f1366ec2a6ba95e35853358284464a (diff) |
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!
Diffstat (limited to 'source/blender/blenkernel/intern/editderivedmesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/editderivedmesh.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 913edba753a..93f7367627f 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); } } } |