guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 01/01: Avoid leaking a file descriptor in test-unwind


From: Mike Gran
Subject: [Guile-commits] 01/01: Avoid leaking a file descriptor in test-unwind
Date: Sat, 9 Feb 2019 19:46:59 -0500 (EST)

mike121 pushed a commit to branch stable-2.2
in repository guile.

commit 1437b76777e576b3d000e2f80c5ecdb33a74ac33
Author: Mike Gran <address@hidden>
Date:   Sat Feb 9 16:39:19 2019 -0800

    Avoid leaking a file descriptor in test-unwind
    
    * test-suite/standalone/test-unwind.c (check_ports): explicitly close temp 
file
---
 test-suite/standalone/test-unwind.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/test-suite/standalone/test-unwind.c 
b/test-suite/standalone/test-unwind.c
index 3aa3e15..2749af2 100644
--- a/test-suite/standalone/test-unwind.c
+++ b/test-suite/standalone/test-unwind.c
@@ -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);
   {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]