1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Avoid leaking a file descriptor in test-unwind

* test-suite/standalone/test-unwind.c (check_ports): explicitly close temp file
This commit is contained in:
Mike Gran 2019-02-09 16:39:19 -08:00 committed by Andy Wingo
parent 99dd8c9020
commit 08926cdcd0

View file

@ -1,4 +1,4 @@
/* Copyright 2004-2005,2008-2010,2013,2018 /* Copyright 2004-2005,2008-2010,2013,2018-2019
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of Guile. This file is part of Guile.
@ -201,6 +201,7 @@ check_ports ()
#define FILENAME_TEMPLATE "/check-ports.XXXXXX" #define FILENAME_TEMPLATE "/check-ports.XXXXXX"
char *filename; char *filename;
const char *tmpdir = getenv ("TMPDIR"); const char *tmpdir = getenv ("TMPDIR");
int fd;
#ifdef __MINGW32__ #ifdef __MINGW32__
extern int mkstemp (char *); extern int mkstemp (char *);
@ -222,8 +223,10 @@ check_ports ()
/* Sanity check: Make sure that `filename' is actually writeable. /* Sanity check: Make sure that `filename' is actually writeable.
We used to use mktemp(3), but that is now considered a security risk. */ 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); exit (EXIT_FAILURE);
close (fd);
scm_dynwind_begin (0); scm_dynwind_begin (0);
{ {