summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gran <spk121@yahoo.com>2019-02-09 16:39:19 -0800
committerAndy Wingo <wingo@pobox.com>2019-05-23 17:29:52 +0200
commit08926cdcd092c741f7fac726c70fff8f178daeea (patch)
tree4af0c65bf4756856b79e1266f6bd97d73a95ddbb
parent99dd8c90204222155d81eaf41b3d6c7b678ee741 (diff)
downloadguile-08926cdcd092c741f7fac726c70fff8f178daeea.tar.gz
Avoid leaking a file descriptor in test-unwind
* test-suite/standalone/test-unwind.c (check_ports): explicitly close temp file
-rw-r--r--test-suite/standalone/test-unwind.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/test-suite/standalone/test-unwind.c b/test-suite/standalone/test-unwind.c
index fe10d2ddc..33752cd22 100644
--- a/test-suite/standalone/test-unwind.c
+++ b/test-suite/standalone/test-unwind.c
@@ -1,4 +1,4 @@
-/* Copyright 2004-2005,2008-2010,2013,2018
+/* Copyright 2004-2005,2008-2010,2013,2018-2019
Free Software Foundation, Inc.
This file is part of Guile.
@@ -201,6 +201,7 @@ check_ports ()
#define FILENAME_TEMPLATE "/check-ports.XXXXXX"
char *filename;
const char *tmpdir = getenv ("TMPDIR");
+ int fd;
#ifdef __MINGW32__
extern int mkstemp (char *);
@@ -222,8 +223,10 @@ check_ports ()
/* Sanity check: Make sure that `filename' is actually writeable.
We used to use mktemp(3), but that is now considered a security risk. */
- if (0 > mkstemp (filename))
+ fd = mkstemp (filename);
+ if (fd < 0)
exit (EXIT_FAILURE);
+ close (fd);
scm_dynwind_begin (0);
{