[gimp/metadata-browser] file-png: Check that PNG structs are created properly



commit c4a8d293d7488a6d43e7684bbcfe101b495af964
Author: Mukund Sivaraman <muks banu com>
Date:   Wed Sep 21 17:08:53 2011 +0530

    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.

 plug-ins/common/file-png.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/common/file-png.c b/plug-ins/common/file-png.c
index 0660e2c..7cfa1d5 100644
--- a/plug-ins/common/file-png.c
+++ b/plug-ins/common/file-png.c
@@ -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)))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]