Don't leak info_ptr.

* io-png.c (gdk_pixbuf__png_image_stop_load): Don't leak info_ptr.

	* io-png.c (gdk_pixbuf__png_image_load): Get rid of unused
	end_info. Also call png_read_end to check proper ending of the png
	file and catch text chunks after the image data.
This commit is contained in:
Matthias Clasen 2002-03-27 22:12:05 +00:00
parent f70bd1e465
commit ec35e8112a
2 changed files with 15 additions and 12 deletions

View File

@ -1,3 +1,11 @@
2002-03-27 Matthias Clasen <maclas@gmx.de>
* io-png.c (gdk_pixbuf__png_image_stop_load): Don't leak info_ptr.
* io-png.c (gdk_pixbuf__png_image_load): Get rid of unused
end_info. Also call png_read_end to check proper ending of the png
file and catch text chunks after the image data.
2002-03-27 Matthias Clasen <maclas@gmx.de> 2002-03-27 Matthias Clasen <maclas@gmx.de>
* io-png.c (gdk_pixbuf__png_image_load, * io-png.c (gdk_pixbuf__png_image_load,

View File

@ -240,7 +240,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
{ {
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr, end_info; png_infop info_ptr;
png_textp text_ptr; png_textp text_ptr;
gint i, ctype, bpp; gint i, ctype, bpp;
png_uint_32 w, h; png_uint_32 w, h;
@ -272,12 +272,6 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
return NULL; return NULL;
} }
end_info = png_create_info_struct (png_ptr);
if (!end_info) {
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return NULL;
}
if (setjmp (png_ptr->jmpbuf)) { if (setjmp (png_ptr->jmpbuf)) {
if (rows) if (rows)
g_free (rows); g_free (rows);
@ -285,7 +279,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
if (pixels) if (pixels)
g_free (pixels); g_free (pixels);
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return NULL; return NULL;
} }
@ -293,7 +287,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
png_read_info (png_ptr, info_ptr); png_read_info (png_ptr, info_ptr);
if (!setup_png_transformations(png_ptr, info_ptr, error, &w, &h, &ctype)) { if (!setup_png_transformations(png_ptr, info_ptr, error, &w, &h, &ctype)) {
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return NULL; return NULL;
} }
@ -314,7 +308,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
_("Insufficient memory to load PNG file")); _("Insufficient memory to load PNG file"));
} }
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return NULL; return NULL;
} }
@ -324,6 +318,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
rows[i] = pixels + i * w * bpp; rows[i] = pixels + i * w * bpp;
png_read_image (png_ptr, rows); png_read_image (png_ptr, rows);
png_read_end (png_ptr, info_ptr);
if (png_get_text (png_ptr, info_ptr, &text_ptr, &num_texts)) { if (png_get_text (png_ptr, info_ptr, &text_ptr, &num_texts)) {
options = g_new (gchar *, num_texts * 2); options = g_new (gchar *, num_texts * 2);
@ -333,7 +328,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
options + 2*i + 1); options + 2*i + 1);
} }
} }
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
g_free (rows); g_free (rows);
if (ctype & PNG_COLOR_MASK_ALPHA) if (ctype & PNG_COLOR_MASK_ALPHA)
@ -511,7 +506,7 @@ gdk_pixbuf__png_image_stop_load (gpointer context, GError **error)
if (lc->pixbuf) if (lc->pixbuf)
g_object_unref (lc->pixbuf); g_object_unref (lc->pixbuf);
png_destroy_read_struct(&lc->png_read_ptr, NULL, NULL); png_destroy_read_struct(&lc->png_read_ptr, &lc->png_info_ptr, NULL);
g_free(lc); g_free(lc);
return TRUE; return TRUE;