Commit 4eeb8759 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/gimpbrush.c app/gimpbrushpipe.c app/pattern_header.h fixed #8150.

2000-10-01  Michael Natterer  <mitch@gimp.org>

	* app/gimpbrush.c
	* app/gimpbrushpipe.c
	* app/pattern_header.h
	* app/patterns.c: (Hopefully) fixed #8150.

	- If something goes wrong during loading, free the resp. object
	  immediately and close it's FD.
	- When destroying, check each pointer before freeing it.
	- Never use if (!gimp_brush_load_brush() || !pattern_load())
	  but check the return values of both calls separately.
	  (the original code tried to free an already destroyed temp_buf).
	- stuff like below (s/sz_PatternHeader/sizeof(PatternHeader)/g etc.)
parent b04bbd9a
2000-10-01 Michael Natterer <mitch@gimp.org>
* app/gimpbrush.c
* app/gimpbrushpipe.c
* app/pattern_header.h
* app/patterns.c: (Hopefully) fixed #8150.
- If something goes wrong during loading, free the resp. object
immediately and close it's FD.
- When destroying, check each pointer before freeing it.
- Never use if (!gimp_brush_load_brush() || !pattern_load())
but check the return values of both calls separately.
(the original code tried to free an already destroyed temp_buf).
- stuff like below (s/sz_PatternHeader/sizeof(PatternHeader)/g etc.)
2000-09-30 Nick Lamb <njl195@zepler.org.uk>
* plug-ins/common/*.c: Add <string.h> where it is called for
......
......@@ -124,7 +124,7 @@ gimp_brush_get_type (void)
GimpBrush *
gimp_brush_new (gchar *filename)
{
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
if (gimp_brush_load (brush, filename))
return brush;
......@@ -215,7 +215,6 @@ gimp_brush_load (GimpBrush *brush,
if (! gimp_brush_load_brush (brush, fp, filename))
{
fclose (fp);
return FALSE;
}
......@@ -243,6 +242,7 @@ gimp_brush_load_brush (GimpBrush *brush,
/* Read in the header size */
if ((fread (buf, 1, sizeof (BrushHeader), fp)) < sizeof (BrushHeader))
{
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......@@ -258,6 +258,7 @@ gimp_brush_load_brush (GimpBrush *brush,
{
if (header.version != 1)
{
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......@@ -279,6 +280,7 @@ gimp_brush_load_brush (GimpBrush *brush,
if ((fread (brush->name, 1, bn_size, fp)) < bn_size)
{
g_message (_("Error in GIMP brush file...aborting."));
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......@@ -311,6 +313,7 @@ gimp_brush_load_brush (GimpBrush *brush,
default:
g_message (_("Unknown brush format version #%d in \"%s\"\n"),
header.version, filename);
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......
......@@ -124,7 +124,7 @@ gimp_brush_get_type (void)
GimpBrush *
gimp_brush_new (gchar *filename)
{
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
if (gimp_brush_load (brush, filename))
return brush;
......@@ -215,7 +215,6 @@ gimp_brush_load (GimpBrush *brush,
if (! gimp_brush_load_brush (brush, fp, filename))
{
fclose (fp);
return FALSE;
}
......@@ -243,6 +242,7 @@ gimp_brush_load_brush (GimpBrush *brush,
/* Read in the header size */
if ((fread (buf, 1, sizeof (BrushHeader), fp)) < sizeof (BrushHeader))
{
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......@@ -258,6 +258,7 @@ gimp_brush_load_brush (GimpBrush *brush,
{
if (header.version != 1)
{
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......@@ -279,6 +280,7 @@ gimp_brush_load_brush (GimpBrush *brush,
if ((fread (brush->name, 1, bn_size, fp)) < bn_size)
{
g_message (_("Error in GIMP brush file...aborting."));
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......@@ -311,6 +313,7 @@ gimp_brush_load_brush (GimpBrush *brush,
default:
g_message (_("Unknown brush format version #%d in \"%s\"\n"),
header.version, filename);
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......
......@@ -52,14 +52,16 @@ gimp_brush_pixmap_destroy (GtkObject *object)
{
GimpBrushPixmap *pixmap;
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (object));
pixmap = GIMP_BRUSH_PIXMAP (object);
temp_buf_free (pixmap->pixmap_mask);
if (pixmap->pixmap_mask)
temp_buf_free (pixmap->pixmap_mask);
if (GTK_OBJECT_CLASS (gimp_brush_class)->destroy)
(* GTK_OBJECT_CLASS (gimp_brush_class)->destroy) (object);
GTK_OBJECT_CLASS (gimp_brush_class)->destroy (object);
}
static void
......@@ -210,14 +212,15 @@ gimp_brush_pipe_destroy (GtkObject *object)
g_free (pipe->stride);
for (i = 1; i < pipe->nbrushes; i++)
gtk_object_unref (GTK_OBJECT (pipe->brushes[i]));
if (pipe->brushes[i])
gtk_object_unref (GTK_OBJECT (pipe->brushes[i]));
g_free (pipe->brushes);
g_free (pipe->select);
g_free (pipe->index);
if (GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy)
(* GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy) (object);
GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy (object);
}
static void
......@@ -234,9 +237,12 @@ gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
void
gimp_brush_pipe_init (GimpBrushPipe *pipe)
{
pipe->current = NULL;
pipe->dimension = 0;
pipe->rank = NULL;
pipe->stride = NULL;
pipe->nbrushes = 0;
pipe->brushes = NULL;
pipe->select = NULL;
pipe->index = NULL;
}
......@@ -319,13 +325,16 @@ gimp_brush_pipe_load (gchar *filename)
{
gimp_pixpipe_params_init (&params);
gimp_pixpipe_params_parse (paramstring, &params);
pipe->dimension = params.dim;
pipe->rank = g_new (gint, pipe->dimension);
pipe->select = g_new (PipeSelectModes, pipe->dimension);
pipe->index = g_new (gint, pipe->dimension);
pipe->rank = g_new0 (gint, pipe->dimension);
pipe->select = g_new0 (PipeSelectModes, pipe->dimension);
pipe->index = g_new0 (gint, pipe->dimension);
/* placement is not used at all ?? */
if (params.free_placement_string)
g_free (params.placement);
for (i = 0; i < pipe->dimension; i++)
{
pipe->rank[i] = params.rank[i];
......@@ -364,7 +373,7 @@ gimp_brush_pipe_load (gchar *filename)
totalcells = 1; /* Not all necessarily present, maybe */
for (i = 0; i < pipe->dimension; i++)
totalcells *= pipe->rank[i];
pipe->stride = g_new (gint, pipe->dimension);
pipe->stride = g_new0 (gint, pipe->dimension);
for (i = 0; i < pipe->dimension; i++)
{
if (i == 0)
......@@ -390,6 +399,10 @@ gimp_brush_pipe_load (gchar *filename)
{
pipe->brushes[pipe->nbrushes] =
GIMP_BRUSH_PIXMAP (gtk_type_new (GIMP_TYPE_BRUSH_PIXMAP));
gtk_object_ref (GTK_OBJECT (pipe->brushes[pipe->nbrushes]));
gtk_object_sink (GTK_OBJECT (pipe->brushes[pipe->nbrushes]));
g_free (GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name);
GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name = NULL;
}
......@@ -398,16 +411,20 @@ gimp_brush_pipe_load (gchar *filename)
/* load the brush */
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[pipe->nbrushes]),
fp, filename)
|| !pattern_load (pattern, fp, filename))
{
g_message (_("Failed to load one of the\n"
"brushes in the brush pipe."));
fclose (fp);
fp, filename))
{
g_message (_("Failed to load one of the brushes in the brush pipe."));
pattern_free (pattern);
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
}
if (!pattern_load (pattern, fp, filename))
{
g_message (_("Failed to load one of the brushes in the brush pipe."));
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
if (pipe->nbrushes == 0)
{
......@@ -415,8 +432,10 @@ gimp_brush_pipe_load (gchar *filename)
g_free (GIMP_BRUSH (pipe)->name);
GIMP_BRUSH (pipe)->name = name;
}
pipe->brushes[pipe->nbrushes]->pixmap_mask = pattern->mask;
g_free (pattern->name);
pipe->nbrushes++;
}
......@@ -432,8 +451,8 @@ GimpBrushPipe *
gimp_brush_pixmap_load (gchar *filename)
{
GimpBrushPipe *pipe;
GPattern *pattern;
FILE *fp;
GPattern *pattern;
FILE *fp;
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
......@@ -460,16 +479,21 @@ gimp_brush_pixmap_load (gchar *filename)
/* load the brush */
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[0]),
fp, filename)
|| !pattern_load (pattern, fp, filename))
fp, filename))
{
g_message (_("Failed to load pixmap brush."));
fclose (fp);
pattern_free (pattern);
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
if (!pattern_load (pattern, fp, filename))
{
g_message (_("Failed to load pixmap brush."));
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
pipe->brushes[0]->pixmap_mask = pattern->mask;
pipe->nbrushes = 1;
......
......@@ -52,14 +52,16 @@ gimp_brush_pixmap_destroy (GtkObject *object)
{
GimpBrushPixmap *pixmap;
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (object));
pixmap = GIMP_BRUSH_PIXMAP (object);
temp_buf_free (pixmap->pixmap_mask);
if (pixmap->pixmap_mask)
temp_buf_free (pixmap->pixmap_mask);
if (GTK_OBJECT_CLASS (gimp_brush_class)->destroy)
(* GTK_OBJECT_CLASS (gimp_brush_class)->destroy) (object);
GTK_OBJECT_CLASS (gimp_brush_class)->destroy (object);
}
static void
......@@ -210,14 +212,15 @@ gimp_brush_pipe_destroy (GtkObject *object)
g_free (pipe->stride);
for (i = 1; i < pipe->nbrushes; i++)
gtk_object_unref (GTK_OBJECT (pipe->brushes[i]));
if (pipe->brushes[i])
gtk_object_unref (GTK_OBJECT (pipe->brushes[i]));
g_free (pipe->brushes);
g_free (pipe->select);
g_free (pipe->index);
if (GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy)
(* GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy) (object);
GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy (object);
}
static void
......@@ -234,9 +237,12 @@ gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
void
gimp_brush_pipe_init (GimpBrushPipe *pipe)
{
pipe->current = NULL;
pipe->dimension = 0;
pipe->rank = NULL;
pipe->stride = NULL;
pipe->nbrushes = 0;
pipe->brushes = NULL;
pipe->select = NULL;
pipe->index = NULL;
}
......@@ -319,13 +325,16 @@ gimp_brush_pipe_load (gchar *filename)
{
gimp_pixpipe_params_init (&params);
gimp_pixpipe_params_parse (paramstring, &params);
pipe->dimension = params.dim;
pipe->rank = g_new (gint, pipe->dimension);
pipe->select = g_new (PipeSelectModes, pipe->dimension);
pipe->index = g_new (gint, pipe->dimension);
pipe->rank = g_new0 (gint, pipe->dimension);
pipe->select = g_new0 (PipeSelectModes, pipe->dimension);
pipe->index = g_new0 (gint, pipe->dimension);
/* placement is not used at all ?? */
if (params.free_placement_string)
g_free (params.placement);
for (i = 0; i < pipe->dimension; i++)
{
pipe->rank[i] = params.rank[i];
......@@ -364,7 +373,7 @@ gimp_brush_pipe_load (gchar *filename)
totalcells = 1; /* Not all necessarily present, maybe */
for (i = 0; i < pipe->dimension; i++)
totalcells *= pipe->rank[i];
pipe->stride = g_new (gint, pipe->dimension);
pipe->stride = g_new0 (gint, pipe->dimension);
for (i = 0; i < pipe->dimension; i++)
{
if (i == 0)
......@@ -390,6 +399,10 @@ gimp_brush_pipe_load (gchar *filename)
{
pipe->brushes[pipe->nbrushes] =
GIMP_BRUSH_PIXMAP (gtk_type_new (GIMP_TYPE_BRUSH_PIXMAP));
gtk_object_ref (GTK_OBJECT (pipe->brushes[pipe->nbrushes]));
gtk_object_sink (GTK_OBJECT (pipe->brushes[pipe->nbrushes]));
g_free (GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name);
GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name = NULL;
}
......@@ -398,16 +411,20 @@ gimp_brush_pipe_load (gchar *filename)
/* load the brush */
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[pipe->nbrushes]),
fp, filename)
|| !pattern_load (pattern, fp, filename))
{
g_message (_("Failed to load one of the\n"
"brushes in the brush pipe."));
fclose (fp);
fp, filename))
{
g_message (_("Failed to load one of the brushes in the brush pipe."));
pattern_free (pattern);
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
}
if (!pattern_load (pattern, fp, filename))
{
g_message (_("Failed to load one of the brushes in the brush pipe."));
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
if (pipe->nbrushes == 0)
{
......@@ -415,8 +432,10 @@ gimp_brush_pipe_load (gchar *filename)
g_free (GIMP_BRUSH (pipe)->name);
GIMP_BRUSH (pipe)->name = name;
}
pipe->brushes[pipe->nbrushes]->pixmap_mask = pattern->mask;
g_free (pattern->name);
pipe->nbrushes++;
}
......@@ -432,8 +451,8 @@ GimpBrushPipe *
gimp_brush_pixmap_load (gchar *filename)
{
GimpBrushPipe *pipe;
GPattern *pattern;
FILE *fp;
GPattern *pattern;
FILE *fp;
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
......@@ -460,16 +479,21 @@ gimp_brush_pixmap_load (gchar *filename)
/* load the brush */
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[0]),
fp, filename)
|| !pattern_load (pattern, fp, filename))
fp, filename))
{
g_message (_("Failed to load pixmap brush."));
fclose (fp);
pattern_free (pattern);
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
if (!pattern_load (pattern, fp, filename))
{
g_message (_("Failed to load pixmap brush."));
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
pipe->brushes[0]->pixmap_mask = pattern->mask;
pipe->nbrushes = 1;
......
......@@ -15,25 +15,25 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PATTERN_HEADER_H__
#define __PATTERN_HEADER_H__
typedef struct _PatternHeader PatternHeader;
#define GPATTERN_FILE_VERSION 1
#define GPATTERN_MAGIC (('G' << 24) + ('P' << 16) + ('A' << 8) + ('T' << 0))
#define sz_PatternHeader (sizeof (PatternHeader))
/* All field entries are MSB */
typedef struct _PatternHeader PatternHeader;
struct _PatternHeader
{
unsigned int header_size; /* header_size = sz_PatternHeader + pattern name */
unsigned int version; /* pattern file version # */
unsigned int width; /* width of pattern */
unsigned int height; /* height of pattern */
unsigned int bytes; /* depth of pattern in bytes */
unsigned int magic_number; /* GIMP pattern magic number */
guint header_size; /* header_size = sizeof(PatternHeader) + pattern name */
guint version; /* pattern file version # */
guint width; /* width of pattern */
guint height; /* height of pattern */
guint bytes; /* depth of pattern in bytes */
guint magic_number; /* GIMP pattern magic number */
};
/* In a pattern file, next comes the pattern name, null-terminated. After that
......
......@@ -124,7 +124,7 @@ gimp_brush_get_type (void)
GimpBrush *
gimp_brush_new (gchar *filename)
{
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
if (gimp_brush_load (brush, filename))
return brush;
......@@ -215,7 +215,6 @@ gimp_brush_load (GimpBrush *brush,
if (! gimp_brush_load_brush (brush, fp, filename))
{
fclose (fp);
return FALSE;
}
......@@ -243,6 +242,7 @@ gimp_brush_load_brush (GimpBrush *brush,
/* Read in the header size */
if ((fread (buf, 1, sizeof (BrushHeader), fp)) < sizeof (BrushHeader))
{
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......@@ -258,6 +258,7 @@ gimp_brush_load_brush (GimpBrush *brush,
{
if (header.version != 1)
{
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......@@ -279,6 +280,7 @@ gimp_brush_load_brush (GimpBrush *brush,
if ((fread (brush->name, 1, bn_size, fp)) < bn_size)
{
g_message (_("Error in GIMP brush file...aborting."));
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......@@ -311,6 +313,7 @@ gimp_brush_load_brush (GimpBrush *brush,
default:
g_message (_("Unknown brush format version #%d in \"%s\"\n"),
header.version, filename);
fclose (fp);
gtk_object_sink (GTK_OBJECT (brush));
return FALSE;
}
......
......@@ -52,14 +52,16 @@ gimp_brush_pixmap_destroy (GtkObject *object)
{
GimpBrushPixmap *pixmap;
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (object));
pixmap = GIMP_BRUSH_PIXMAP (object);
temp_buf_free (pixmap->pixmap_mask);
if (pixmap->pixmap_mask)
temp_buf_free (pixmap->pixmap_mask);
if (GTK_OBJECT_CLASS (gimp_brush_class)->destroy)
(* GTK_OBJECT_CLASS (gimp_brush_class)->destroy) (object);
GTK_OBJECT_CLASS (gimp_brush_class)->destroy (object);
}
static void
......@@ -210,14 +212,15 @@ gimp_brush_pipe_destroy (GtkObject *object)
g_free (pipe->stride);
for (i = 1; i < pipe->nbrushes; i++)
gtk_object_unref (GTK_OBJECT (pipe->brushes[i]));
if (pipe->brushes[i])
gtk_object_unref (GTK_OBJECT (pipe->brushes[i]));
g_free (pipe->brushes);
g_free (pipe->select);
g_free (pipe->index);
if (GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy)
(* GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy) (object);
GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy (object);
}
static void
......@@ -234,9 +237,12 @@ gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
void
gimp_brush_pipe_init (GimpBrushPipe *pipe)
{
pipe->current = NULL;
pipe->dimension = 0;
pipe->rank = NULL;
pipe->stride = NULL;
pipe->nbrushes = 0;
pipe->brushes = NULL;
pipe->select = NULL;
pipe->index = NULL;
}
......@@ -319,13 +325,16 @@ gimp_brush_pipe_load (gchar *filename)
{
gimp_pixpipe_params_init (&params);
gimp_pixpipe_params_parse (paramstring, &params);
pipe->dimension = params.dim;
pipe->rank = g_new (gint, pipe->dimension);
pipe->select = g_new (PipeSelectModes, pipe->dimension);
pipe->index = g_new (gint, pipe->dimension);
pipe->rank = g_new0 (gint, pipe->dimension);
pipe->select = g_new0 (PipeSelectModes, pipe->dimension);
pipe->index = g_new0 (gint, pipe->dimension);
/* placement is not used at all ?? */
if (params.free_placement_string)
g_free (params.placement);
for (i = 0; i < pipe->dimension; i++)
{
pipe->rank[i] = params.rank[i];
......@@ -364,7 +373,7 @@ gimp_brush_pipe_load (gchar *filename)
totalcells = 1; /* Not all necessarily present, maybe */
for (i = 0; i < pipe->dimension; i++)
totalcells *= pipe->rank[i];
pipe->stride = g_new (gint, pipe->dimension);
pipe->stride = g_new0 (gint, pipe->dimension);
for (i = 0; i < pipe->dimension; i++)
{
if (i == 0)
......@@ -390,6 +399,10 @@ gimp_brush_pipe_load (gchar *filename)
{
pipe->brushes[pipe->nbrushes] =
GIMP_BRUSH_PIXMAP (gtk_type_new (GIMP_TYPE_BRUSH_PIXMAP));
gtk_object_ref (GTK_OBJECT (pipe->brushes[pipe->nbrushes]));
gtk_object_sink (GTK_OBJECT (pipe->brushes[pipe->nbrushes]));
g_free (GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name);
GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name = NULL;
}
......@@ -398,16 +411,20 @@ gimp_brush_pipe_load (gchar *filename)
/* load the brush */
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[pipe->nbrushes]),
fp, filename)
|| !pattern_load (pattern, fp, filename))
{
g_message (_("Failed to load one of the\n"
"brushes in the brush pipe."));
fclose (fp);
fp, filename))
{
g_message (_("Failed to load one of the brushes in the brush pipe."));
pattern_free (pattern);
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
}
if (!pattern_load (pattern, fp, filename))
{
g_message (_("Failed to load one of the brushes in the brush pipe."));
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
if (pipe->nbrushes == 0)
{
......@@ -415,8 +432,10 @@ gimp_brush_pipe_load (gchar *filename)
g_free (GIMP_BRUSH (pipe)->name);
GIMP_BRUSH (pipe)->name = name;
}
pipe->brushes[pipe->nbrushes]->pixmap_mask = pattern->mask;
g_free (pattern->name);
pipe->nbrushes++;
}
......@@ -432,8 +451,8 @@ GimpBrushPipe *
gimp_brush_pixmap_load (gchar *filename)
{
GimpBrushPipe *pipe;
GPattern *pattern;
FILE *fp;
GPattern *pattern;
FILE *fp;
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
......@@ -460,16 +479,21 @@ gimp_brush_pixmap_load (gchar *filename)
/* load the brush */
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[0]),
fp, filename)
|| !pattern_load (pattern, fp, filename))
fp, filename))
{
g_message (_("Failed to load pixmap brush."));
fclose (fp);
pattern_free (pattern);
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
if (!pattern_load (pattern, fp, filename))
{
g_message (_("Failed to load pixmap brush."));
gtk_object_sink (GTK_OBJECT (pipe));
return NULL;
}
pipe->brushes[0]->pixmap_mask = pattern->mask;
pipe->nbrushes = 1;
......
......@@ -15,25 +15,25 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PATTERN_HEADER_H__
#define __PATTERN_HEADER_H__
typedef struct _PatternHeader PatternHeader;
#define GPATTERN_FILE_VERSION 1
#define GPATTERN_MAGIC (('G' << 24) + ('P' << 16) + ('A' << 8) + ('T' << 0))
#define sz_PatternHeader (sizeof (PatternHeader))
/* All field entries are MSB */