file-png: Check that PNG structs are created properly

If there's a version mismatch between compiled version (header) and
installed shared libpng library, structs are not created and NULL is
returned.
This commit is contained in:
Mukund Sivaraman 2011-09-21 17:08:53 +05:30
parent 3145c80aba
commit 1ac6c7b85c

View file

@ -720,6 +720,14 @@ load_image (const gchar *filename,
gint num_texts;
pp = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!pp)
{
g_set_error (error, 0, 0,
_("Error creating PNG read struct while saving '%s'."),
gimp_filename_to_utf8 (filename));
return FALSE;
}
info = png_create_info_struct (pp);
if (setjmp (png_jmpbuf (pp)))
@ -1247,6 +1255,14 @@ save_image (const gchar *filename,
png_textp text = NULL;
pp = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!pp)
{
g_set_error (error, 0, 0,
_("Error creating PNG write struct while saving '%s'."),
gimp_filename_to_utf8 (filename));
return FALSE;
}
info = png_create_info_struct (pp);
if (setjmp (png_jmpbuf (pp)))