[gegl] ppm-load: Fix leak of file handles when input is not a PPM file
- From: Mukund Sivaraman <muks src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] ppm-load: Fix leak of file handles when input is not a PPM file
- Date: Thu, 24 Jun 2010 17:36:22 +0000 (UTC)
commit 0ba03e293600fef491e0225dd035e9b0ff9aab20
Author: Mukund Sivaraman <muks banu com>
Date: Thu Jun 24 23:04:59 2010 +0530
ppm-load: Fix leak of file handles when input is not a PPM file
operations/external/ppm-load.c | 37 ++++++++++++++++---------------------
1 files changed, 16 insertions(+), 21 deletions(-)
---
diff --git a/operations/external/ppm-load.c b/operations/external/ppm-load.c
index c20f337..efff4c6 100644
--- a/operations/external/ppm-load.c
+++ b/operations/external/ppm-load.c
@@ -179,19 +179,10 @@ get_bounding_box (GeglOperation *operation)
fp = (!strcmp (o->path, "-") ? stdin : fopen (o->path,"rb") );
if (!fp)
- {
- return result;
- }
+ return result;
if (!ppm_load_read_header (fp, &img))
- {
- return result;
- }
-
- if (stdin != fp)
- {
- fclose (fp);
- }
+ goto out;
switch (img.bpc)
{
@@ -212,6 +203,10 @@ get_bounding_box (GeglOperation *operation)
result.width = img.width;
result.height = img.height;
+ out:
+ if (stdin != fp)
+ fclose (fp);
+
return result;
}
@@ -224,18 +219,15 @@ process (GeglOperation *operation,
FILE *fp;
pnm_struct img;
GeglRectangle rect = {0,0,0,0};
+ gboolean ret = FALSE;
fp = (!strcmp (o->path, "-") ? stdin : fopen (o->path,"rb"));
if (!fp)
- {
- return FALSE;
- }
+ return FALSE;
if (!ppm_load_read_header (fp, &img))
- {
- return FALSE;
- }
+ goto out;
rect.height = img.height;
rect.width = img.width;
@@ -278,11 +270,14 @@ process (GeglOperation *operation,
}
g_free (img.data);
+
+ ret = TRUE;
+
+ out:
if (stdin != fp)
- {
- fclose (fp);
- }
- return TRUE;
+ fclose (fp);
+
+ return ret;
}
static GeglRectangle
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]