summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-08-07 10:34:50 +0200
committerColin Walters <walters@verbum.org>2013-08-07 10:34:50 +0200
commitd2deea193d946cba7778a726e45ede0ac56db715 (patch)
tree5ad98a381fb016d030d7177bcf8aca2eaafc355d
parent3dee2f23ac34d1d5ce2ed8cbad14cb0596d2b57f (diff)
downloadlibgsystem-d2deea193d946cba7778a726e45ede0ac56db715.tar.gz
fileutils: Fix fd leak
-rw-r--r--gsystem-file-utils.c5
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;
}