Fix a few memory leaks in the, most of them in error cases but one or two

1999-07-18  Larry Ewing  <lewing@gimp.org>

	* src/io-xpm.c:
	* src/io-gif.c:
	* src/io-png.c:
	* src/io-jpeg.c: Fix a few memory leaks in the, most of them in
	error cases but one or two in the common case.  There are probably
	a few small ones left.
This commit is contained in:
Larry Ewing 1999-07-19 04:21:09 +00:00 committed by Larry Ewing
parent 6423183a63
commit e0fe931832
5 changed files with 35 additions and 9 deletions

View File

@ -1,3 +1,12 @@
1999-07-18 Larry Ewing <lewing@gimp.org>
* src/io-xpm.c:
* src/io-gif.c:
* src/io-png.c:
* src/io-jpeg.c: Fix a few memory leaks in the, most of them in
error cases but one or two in the common case. There are probably
a few small ones left.
1999-07-18 Mark Crichton <crichton@gimp.org>
* configure.in: removed version.h.
@ -59,4 +68,4 @@
1999-07-13 Mark Crichton <crichton@gimp.org>
* configure.in: I am a bonehead. Added gif-lib check.
* configure.in: I am a bonehead. Added gif-lib check.

View File

@ -154,7 +154,9 @@ GdkPixBuf *image_load(FILE * f)
tmpptr[3] = 0xFF;
tmpptr += (is_trans ? 4 : 3);
}
g_free(rows[i]);
}
g_free(rows);
/* Ok, now stuff the GdkPixBuf with goodies */
@ -167,6 +169,7 @@ GdkPixBuf *image_load(FILE * f)
/* Ok, I'm anal...shoot me */
if (!(pixbuf->art_pixbuf)) {
art_free(pixels);
g_free(pixbuf);
return NULL;
}
@ -178,3 +181,5 @@ GdkPixBuf *image_load(FILE * f)
}
image_save() {}

View File

@ -116,8 +116,11 @@ GdkPixBuf *image_load(FILE *f)
/* finish off, create the pixbuf */
pixbuf = g_new(GdkPixBuf, 1);
pixbuf->art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
if (!(pixbuf->art_pixbuf))
if (!(pixbuf->art_pixbuf)) {
art_free(pixels);
g_free(pixbuf);
return NULL;
}
pixbuf->ref_count = 0;
pixbuf->unref_func = NULL;

View File

@ -115,6 +115,7 @@ GdkPixBuf *image_load(FILE * f)
for (n = 0; n < i; n++)
g_free(rows[i]);
g_free(rows);
art_free(pixels);
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return NULL;
}
@ -151,8 +152,12 @@ GdkPixBuf *image_load(FILE * f)
pixbuf->art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
/* Ok, I'm anal...shoot me */
if (!(pixbuf->art_pixbuf))
if (!(pixbuf->art_pixbuf)) {
art_free(pixels);
g_free(pixbuf);
return NULL;
}
pixbuf->ref_count = 0;
pixbuf->unref_func = NULL;

View File

@ -329,6 +329,7 @@ static GdkPixBuf *
buffer = (*get_buf) (op_cmap, handle);
if (!buffer) {
g_warning("Can't load XPM colormap");
g_hash_table_destroy(color_hash);
g_free(name_buf);
g_free(colors);
return NULL;
@ -396,6 +397,9 @@ static GdkPixBuf *
}
}
}
g_hash_table_destroy(color_hash);
g_free(colors);
g_free(name_buf);
/* Ok, now stuff the GdkPixBuf with goodies */
@ -407,15 +411,15 @@ static GdkPixBuf *
pixbuf->art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
/* Ok, I'm anal...shoot me */
if (!(pixbuf->art_pixbuf))
return NULL;
if (!(pixbuf->art_pixbuf)) {
art_free(pixels);
g_free(pixbuf);
return NULL;
}
pixbuf->ref_count = 0;
pixbuf->unref_func = NULL;
g_hash_table_destroy(color_hash);
g_free(colors);
g_free(name_buf);
return pixbuf;
}