[gegl] ppm-save: Fix leak of file handles when we don't support the output type



commit 21eb523f762c5edd85752d3e546b01aebb42c90b
Author: Mukund Sivaraman <muks banu com>
Date:   Thu Jun 24 23:05:39 2010 +0530

    ppm-save: Fix leak of file handles when we don't support the output type

 operations/external/ppm-save.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/operations/external/ppm-save.c b/operations/external/ppm-save.c
index fcacb55..9e55593 100644
--- a/operations/external/ppm-save.c
+++ b/operations/external/ppm-save.c
@@ -122,17 +122,17 @@ process (GeglOperation       *operation,
   map_type  type;
   gsize     bpc;
   gsize     numsamples;
+  gboolean  ret = FALSE;
 
   fp = (!strcmp (o->path, "-") ? stdout : fopen(o->path, "wb") );
+
   if (!fp)
-    {
-      return FALSE;
-    }
+    return FALSE;
 
   if ((o->bitdepth != 8) && (o->bitdepth != 16))
     {
       g_warning ("Bitdepths of 8 and 16 are only accepted currently.");
-      return FALSE;
+      goto out;
     }
 
   type = (o->rawformat ? PIXMAP_RAW : PIXMAP_ASCII);
@@ -161,12 +161,13 @@ process (GeglOperation       *operation,
 
   g_free (data);
 
+  ret = TRUE;
+
+ out:
   if (fp != stdout)
-    {
-      fclose( fp );
-    }
+    fclose( fp );
 
-  return TRUE;
+  return ret;
 }
 
 



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