Fix invalid memory access in gradient brushes - could cause a crash in

MacOS.

This looks like an oldie and should not influence release, but if we do
make an 'a' build it's safe to include.

Report by Craig Jones, thanks!
This commit is contained in:
Antonis Ryakiotakis 2015-01-07 23:01:42 +01:00 committed by Campbell Barton
parent 67439dfe06
commit 012f7ca1b5
1 changed files with 5 additions and 3 deletions

View File

@ -662,22 +662,24 @@ void paint_brush_color_get(struct Scene *scene, struct Brush *br, bool color_cor
copy_v3_v3(color, BKE_brush_secondary_color_get(scene, br));
else {
if (br->flag & BRUSH_USE_GRADIENT) {
float color_gr[4];
switch (br->gradient_stroke_mode) {
case BRUSH_GRADIENT_PRESSURE:
do_colorband(br->gradient, pressure, color);
do_colorband(br->gradient, pressure, color_gr);
break;
case BRUSH_GRADIENT_SPACING_REPEAT:
{
float coord = fmod(distance / br->gradient_spacing, 1.0);
do_colorband(br->gradient, coord, color);
do_colorband(br->gradient, coord, color_gr);
break;
}
case BRUSH_GRADIENT_SPACING_CLAMP:
{
do_colorband(br->gradient, distance / br->gradient_spacing, color);
do_colorband(br->gradient, distance / br->gradient_spacing, color_gr);
break;
}
}
copy_v3_v3(color, color_gr);
}
else
copy_v3_v3(color, BKE_brush_color_get(scene, br));