diff --git a/ChangeLog b/ChangeLog index 4989992289..dd8bc2d35d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-08-03 Michael Natterer + + * app/core/gimpbrushgenerated.c (gimp_brush_generated_load): don't + leak the brush's name if parsing the shape fails. + + (gimp_brush_generated_dirty): shut up bogus compiler warnings + about uninitialized variables. + 2004-08-03 Shlomi Fish * plug-ins/imagemap/imap_preview.c diff --git a/app/core/gimpbrushgenerated-load.c b/app/core/gimpbrushgenerated-load.c index f298886e36..417b5d5c45 100644 --- a/app/core/gimpbrushgenerated-load.c +++ b/app/core/gimpbrushgenerated-load.c @@ -373,7 +373,8 @@ gimp_brush_generated_dirty (GimpData *data) gdouble exponent; guchar a; gint length; - gint width, height; + gint width = 0; + gint height = 0; guchar *lookup; gdouble sum; gdouble c, s, cs, ss; @@ -395,20 +396,25 @@ gimp_brush_generated_dirty (GimpData *data) switch (brush->shape) { - case GIMP_BRUSH_GENERATED_CIRCLE: - width = ceil (sqrt (gbrush->x_axis.x * gbrush->x_axis.x + - gbrush->y_axis.x * gbrush->y_axis.x)); - height = ceil (sqrt (gbrush->x_axis.y * gbrush->x_axis.y + - gbrush->y_axis.y * gbrush->y_axis.y)); - break; - case GIMP_BRUSH_GENERATED_SQUARE: - width = ceil (fabs (gbrush->x_axis.x) + fabs (gbrush->y_axis.x)); - height = ceil (fabs (gbrush->x_axis.y) + fabs (gbrush->y_axis.y)); - break; - case GIMP_BRUSH_GENERATED_DIAMOND: - width = ceil (MAX (fabs (gbrush->x_axis.x), fabs (gbrush->y_axis.x))); - height = ceil (MAX (fabs (gbrush->x_axis.y), fabs (gbrush->y_axis.y))); - break; + case GIMP_BRUSH_GENERATED_CIRCLE: + width = ceil (sqrt (gbrush->x_axis.x * gbrush->x_axis.x + + gbrush->y_axis.x * gbrush->y_axis.x)); + height = ceil (sqrt (gbrush->x_axis.y * gbrush->x_axis.y + + gbrush->y_axis.y * gbrush->y_axis.y)); + break; + + case GIMP_BRUSH_GENERATED_SQUARE: + width = ceil (fabs (gbrush->x_axis.x) + fabs (gbrush->y_axis.x)); + height = ceil (fabs (gbrush->x_axis.y) + fabs (gbrush->y_axis.y)); + break; + + case GIMP_BRUSH_GENERATED_DIAMOND: + width = ceil (MAX (fabs (gbrush->x_axis.x), fabs (gbrush->y_axis.x))); + height = ceil (MAX (fabs (gbrush->x_axis.y), fabs (gbrush->y_axis.y))); + break; + + default: + g_return_if_reached (); } if (brush->spikes > 2) @@ -489,7 +495,7 @@ gimp_brush_generated_dirty (GimpData *data) while (angle > G_PI / brush->spikes) { gdouble sx = tx, sy = ty; - + tx = cs * sx - ss * sy; ty = ss * sx + cs * sy; @@ -500,15 +506,15 @@ gimp_brush_generated_dirty (GimpData *data) ty *= brush->aspect_ratio; switch (brush->shape) { - case GIMP_BRUSH_GENERATED_CIRCLE: - d = sqrt (tx*tx + ty*ty); - break; - case GIMP_BRUSH_GENERATED_SQUARE: - d = MAX (fabs (tx), fabs (ty)); - break; - case GIMP_BRUSH_GENERATED_DIAMOND: - d = fabs (tx) + fabs (ty); - break; + case GIMP_BRUSH_GENERATED_CIRCLE: + d = sqrt (tx*tx + ty*ty); + break; + case GIMP_BRUSH_GENERATED_SQUARE: + d = MAX (fabs (tx), fabs (ty)); + break; + case GIMP_BRUSH_GENERATED_DIAMOND: + d = fabs (tx) + fabs (ty); + break; } if (d < brush->radius + 1) @@ -662,6 +668,7 @@ gimp_brush_generated_load (const gchar *filename, _("Fatal parse error in brush file '%s': " "Unknown GIMP brush shape."), gimp_filename_to_utf8 (filename)); + g_free (name); return NULL; } diff --git a/app/core/gimpbrushgenerated-save.c b/app/core/gimpbrushgenerated-save.c index f298886e36..417b5d5c45 100644 --- a/app/core/gimpbrushgenerated-save.c +++ b/app/core/gimpbrushgenerated-save.c @@ -373,7 +373,8 @@ gimp_brush_generated_dirty (GimpData *data) gdouble exponent; guchar a; gint length; - gint width, height; + gint width = 0; + gint height = 0; guchar *lookup; gdouble sum; gdouble c, s, cs, ss; @@ -395,20 +396,25 @@ gimp_brush_generated_dirty (GimpData *data) switch (brush->shape) { - case GIMP_BRUSH_GENERATED_CIRCLE: - width = ceil (sqrt (gbrush->x_axis.x * gbrush->x_axis.x + - gbrush->y_axis.x * gbrush->y_axis.x)); - height = ceil (sqrt (gbrush->x_axis.y * gbrush->x_axis.y + - gbrush->y_axis.y * gbrush->y_axis.y)); - break; - case GIMP_BRUSH_GENERATED_SQUARE: - width = ceil (fabs (gbrush->x_axis.x) + fabs (gbrush->y_axis.x)); - height = ceil (fabs (gbrush->x_axis.y) + fabs (gbrush->y_axis.y)); - break; - case GIMP_BRUSH_GENERATED_DIAMOND: - width = ceil (MAX (fabs (gbrush->x_axis.x), fabs (gbrush->y_axis.x))); - height = ceil (MAX (fabs (gbrush->x_axis.y), fabs (gbrush->y_axis.y))); - break; + case GIMP_BRUSH_GENERATED_CIRCLE: + width = ceil (sqrt (gbrush->x_axis.x * gbrush->x_axis.x + + gbrush->y_axis.x * gbrush->y_axis.x)); + height = ceil (sqrt (gbrush->x_axis.y * gbrush->x_axis.y + + gbrush->y_axis.y * gbrush->y_axis.y)); + break; + + case GIMP_BRUSH_GENERATED_SQUARE: + width = ceil (fabs (gbrush->x_axis.x) + fabs (gbrush->y_axis.x)); + height = ceil (fabs (gbrush->x_axis.y) + fabs (gbrush->y_axis.y)); + break; + + case GIMP_BRUSH_GENERATED_DIAMOND: + width = ceil (MAX (fabs (gbrush->x_axis.x), fabs (gbrush->y_axis.x))); + height = ceil (MAX (fabs (gbrush->x_axis.y), fabs (gbrush->y_axis.y))); + break; + + default: + g_return_if_reached (); } if (brush->spikes > 2) @@ -489,7 +495,7 @@ gimp_brush_generated_dirty (GimpData *data) while (angle > G_PI / brush->spikes) { gdouble sx = tx, sy = ty; - + tx = cs * sx - ss * sy; ty = ss * sx + cs * sy; @@ -500,15 +506,15 @@ gimp_brush_generated_dirty (GimpData *data) ty *= brush->aspect_ratio; switch (brush->shape) { - case GIMP_BRUSH_GENERATED_CIRCLE: - d = sqrt (tx*tx + ty*ty); - break; - case GIMP_BRUSH_GENERATED_SQUARE: - d = MAX (fabs (tx), fabs (ty)); - break; - case GIMP_BRUSH_GENERATED_DIAMOND: - d = fabs (tx) + fabs (ty); - break; + case GIMP_BRUSH_GENERATED_CIRCLE: + d = sqrt (tx*tx + ty*ty); + break; + case GIMP_BRUSH_GENERATED_SQUARE: + d = MAX (fabs (tx), fabs (ty)); + break; + case GIMP_BRUSH_GENERATED_DIAMOND: + d = fabs (tx) + fabs (ty); + break; } if (d < brush->radius + 1) @@ -662,6 +668,7 @@ gimp_brush_generated_load (const gchar *filename, _("Fatal parse error in brush file '%s': " "Unknown GIMP brush shape."), gimp_filename_to_utf8 (filename)); + g_free (name); return NULL; } diff --git a/app/core/gimpbrushgenerated.c b/app/core/gimpbrushgenerated.c index f298886e36..417b5d5c45 100644 --- a/app/core/gimpbrushgenerated.c +++ b/app/core/gimpbrushgenerated.c @@ -373,7 +373,8 @@ gimp_brush_generated_dirty (GimpData *data) gdouble exponent; guchar a; gint length; - gint width, height; + gint width = 0; + gint height = 0; guchar *lookup; gdouble sum; gdouble c, s, cs, ss; @@ -395,20 +396,25 @@ gimp_brush_generated_dirty (GimpData *data) switch (brush->shape) { - case GIMP_BRUSH_GENERATED_CIRCLE: - width = ceil (sqrt (gbrush->x_axis.x * gbrush->x_axis.x + - gbrush->y_axis.x * gbrush->y_axis.x)); - height = ceil (sqrt (gbrush->x_axis.y * gbrush->x_axis.y + - gbrush->y_axis.y * gbrush->y_axis.y)); - break; - case GIMP_BRUSH_GENERATED_SQUARE: - width = ceil (fabs (gbrush->x_axis.x) + fabs (gbrush->y_axis.x)); - height = ceil (fabs (gbrush->x_axis.y) + fabs (gbrush->y_axis.y)); - break; - case GIMP_BRUSH_GENERATED_DIAMOND: - width = ceil (MAX (fabs (gbrush->x_axis.x), fabs (gbrush->y_axis.x))); - height = ceil (MAX (fabs (gbrush->x_axis.y), fabs (gbrush->y_axis.y))); - break; + case GIMP_BRUSH_GENERATED_CIRCLE: + width = ceil (sqrt (gbrush->x_axis.x * gbrush->x_axis.x + + gbrush->y_axis.x * gbrush->y_axis.x)); + height = ceil (sqrt (gbrush->x_axis.y * gbrush->x_axis.y + + gbrush->y_axis.y * gbrush->y_axis.y)); + break; + + case GIMP_BRUSH_GENERATED_SQUARE: + width = ceil (fabs (gbrush->x_axis.x) + fabs (gbrush->y_axis.x)); + height = ceil (fabs (gbrush->x_axis.y) + fabs (gbrush->y_axis.y)); + break; + + case GIMP_BRUSH_GENERATED_DIAMOND: + width = ceil (MAX (fabs (gbrush->x_axis.x), fabs (gbrush->y_axis.x))); + height = ceil (MAX (fabs (gbrush->x_axis.y), fabs (gbrush->y_axis.y))); + break; + + default: + g_return_if_reached (); } if (brush->spikes > 2) @@ -489,7 +495,7 @@ gimp_brush_generated_dirty (GimpData *data) while (angle > G_PI / brush->spikes) { gdouble sx = tx, sy = ty; - + tx = cs * sx - ss * sy; ty = ss * sx + cs * sy; @@ -500,15 +506,15 @@ gimp_brush_generated_dirty (GimpData *data) ty *= brush->aspect_ratio; switch (brush->shape) { - case GIMP_BRUSH_GENERATED_CIRCLE: - d = sqrt (tx*tx + ty*ty); - break; - case GIMP_BRUSH_GENERATED_SQUARE: - d = MAX (fabs (tx), fabs (ty)); - break; - case GIMP_BRUSH_GENERATED_DIAMOND: - d = fabs (tx) + fabs (ty); - break; + case GIMP_BRUSH_GENERATED_CIRCLE: + d = sqrt (tx*tx + ty*ty); + break; + case GIMP_BRUSH_GENERATED_SQUARE: + d = MAX (fabs (tx), fabs (ty)); + break; + case GIMP_BRUSH_GENERATED_DIAMOND: + d = fabs (tx) + fabs (ty); + break; } if (d < brush->radius + 1) @@ -662,6 +668,7 @@ gimp_brush_generated_load (const gchar *filename, _("Fatal parse error in brush file '%s': " "Unknown GIMP brush shape."), gimp_filename_to_utf8 (filename)); + g_free (name); return NULL; }