mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
app: avoid reading uninitialized memory
gimp_rgb_to_hsl and hsl_to_rgb reads the a member, so set it before calling them. Add gimp_hsl_set_alpha() for this purpose. Found by coverity
This commit is contained in:
parent
4852e59ec1
commit
1947d8def8
5 changed files with 24 additions and 4 deletions
|
@ -88,8 +88,8 @@ gimp_colorize_config_class_init (GimpColorizeConfigClass *klass)
|
|||
-1.0, 1.0, 0.0, 0);
|
||||
|
||||
gimp_hsl_set (&hsl, 0.5, 0.5, 0.5);
|
||||
gimp_hsl_set_alpha (&hsl, 1.0);
|
||||
gimp_hsl_to_rgb (&hsl, &rgb);
|
||||
gimp_rgb_set_alpha (&rgb, 1.0);
|
||||
|
||||
g_object_class_install_property (object_class, PROP_COLOR,
|
||||
gimp_param_spec_rgb ("color",
|
||||
|
@ -135,8 +135,8 @@ gimp_colorize_config_get_property (GObject *object,
|
|||
self->hue,
|
||||
self->saturation,
|
||||
(self->lightness + 1.0) / 2.0);
|
||||
gimp_hsl_set_alpha (&hsl, 1.0);
|
||||
gimp_hsl_to_rgb (&hsl, &rgb);
|
||||
gimp_rgb_set_alpha (&rgb, 1.0);
|
||||
gimp_value_set_rgb (value, &rgb);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -98,6 +98,7 @@ gimp_operation_colorize_process (GeglOperation *operation,
|
|||
|
||||
hsl.h = config->hue;
|
||||
hsl.s = config->saturation;
|
||||
hsl.a = src[ALPHA];
|
||||
|
||||
while (samples--)
|
||||
{
|
||||
|
@ -129,7 +130,7 @@ gimp_operation_colorize_process (GeglOperation *operation,
|
|||
dest[RED] = rgb.r; /* * lum; */
|
||||
dest[GREEN] = rgb.g; /* * lum; */
|
||||
dest[BLUE] = rgb.b; /* * lum */;
|
||||
dest[ALPHA] = src[ALPHA];
|
||||
dest[ALPHA] = rgb.a;
|
||||
|
||||
src += 4;
|
||||
dest += 4;
|
||||
|
|
|
@ -162,6 +162,7 @@ gimp_operation_hue_saturation_process (GeglOperation *operation,
|
|||
rgb.r = src[RED];
|
||||
rgb.g = src[GREEN];
|
||||
rgb.b = src[BLUE];
|
||||
rgb.a = src[ALPHA];
|
||||
|
||||
gimp_rgb_to_hsl (&rgb, &hsl);
|
||||
|
||||
|
@ -253,7 +254,7 @@ gimp_operation_hue_saturation_process (GeglOperation *operation,
|
|||
dest[RED] = rgb.r;
|
||||
dest[GREEN] = rgb.g;
|
||||
dest[BLUE] = rgb.b;
|
||||
dest[ALPHA] = src[ALPHA];
|
||||
dest[ALPHA] = rgb.a;
|
||||
|
||||
src += 4;
|
||||
dest += 4;
|
||||
|
|
|
@ -75,3 +75,19 @@ gimp_hsl_set (GimpHSL *hsl,
|
|||
hsl->s = s;
|
||||
hsl->l = l;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_hsl_set_alpha:
|
||||
* @hsl:
|
||||
* @a:
|
||||
*
|
||||
* Since: GIMP 2.10
|
||||
**/
|
||||
void
|
||||
gimp_hsl_set_alpha (GimpHSL *hsl,
|
||||
gdouble a)
|
||||
{
|
||||
g_return_if_fail (hsl != NULL);
|
||||
|
||||
hsl->a = a;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ void gimp_hsl_set (GimpHSL *hsl,
|
|||
gdouble h,
|
||||
gdouble s,
|
||||
gdouble l);
|
||||
void gimp_hsl_set_alpha (GimpHSL *hsl,
|
||||
gdouble a);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue