[libgsystem] fileutils: Fix fd leak



commit d2deea193d946cba7778a726e45ede0ac56db715
Author: Colin Walters <walters verbum org>
Date:   Wed Aug 7 10:34:50 2013 +0200

    fileutils: Fix fd leak

 gsystem-file-utils.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/gsystem-file-utils.c b/gsystem-file-utils.c
index c25b309..28c55d9 100644
--- a/gsystem-file-utils.c
+++ b/gsystem-file-utils.c
@@ -454,8 +454,8 @@ gs_file_open_in_tmpdir (GFile             *tmpdir,
   gboolean ret = FALSE;
   const int max_attempts = 128;
   guint i;
-  DIR *d;
-  int dfd;
+  DIR *d = NULL;
+  int dfd = -1;
   char *tmp_name = NULL;
   int fd;
 
@@ -495,6 +495,7 @@ gs_file_open_in_tmpdir (GFile             *tmpdir,
   if (out_stream)
     *out_stream = g_unix_output_stream_new (fd, TRUE);
  out:
+  if (d) (void) closedir (d);
   return ret;
 }
 


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