mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 21:40:33 +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:
parent
139c702fc8
commit
1437b76777
1 changed files with 5 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2004, 2005, 2008, 2009, 2010, 2013 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2004, 2005, 2008, 2009, 2010, 2013, 2019 Free Software Foundation, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
|
@ -200,6 +200,7 @@ check_ports ()
|
|||
#define FILENAME_TEMPLATE "/check-ports.XXXXXX"
|
||||
char *filename;
|
||||
const char *tmpdir = getenv ("TMPDIR");
|
||||
int fd;
|
||||
#ifdef __MINGW32__
|
||||
extern int mkstemp (char *);
|
||||
|
||||
|
@ -221,8 +222,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);
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue