libctf, link: fix ctf_link_write fd leak
authorNick Alcock <nick.alcock@oracle.com>
Thu, 4 Jun 2020 18:49:36 +0000 (19:49 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Wed, 22 Jul 2020 17:02:18 +0000 (18:02 +0100)
We were leaking the fd on every invocation.

libctf/
* ctf-link.c (ctf_link_write): Close the fd.

libctf/ChangeLog
libctf/ctf-link.c

index c3451ee5aa6c7323cb088415ce11db2a4c64fce8..848bc48b1e8131bf25456c8ffb564d67a134fdad 100644 (file)
@@ -1,3 +1,7 @@
+2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-link.c (ctf_link_write): Close the fd.
+
 2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
 
        * Makefile.am: Set -DNOBFD=1 in libctf-nobfd, and =0 elsewhere.
index 705701d0eb52fb1815c0344874ffe957dae7389e..fa15c9bf9bbe8717c5a8d8a2e223aecec4120a7d 100644 (file)
@@ -1071,6 +1071,7 @@ ctf_link_write (ctf_file_t *fp, size_t *size, size_t threshold)
        free (arg.dynames[i]);
       free (arg.dynames);
     }
+  fclose (f);
   return buf;
 
  err_no: