Hi All,

>From NetBSD:
Fix file descriptor leak. Found by cppcheck. 

Index: src/libexec/ld.so/ldconfig/ldconfig.c
===================================================================
RCS file: /cvs/src/libexec/ld.so/ldconfig/ldconfig.c,v
retrieving revision 1.31
diff -u -p -r1.31 ldconfig.c
--- src/libexec/ld.so/ldconfig/ldconfig.c       13 Nov 2013 05:41:42 -0000      
1.31
+++ src/libexec/ld.so/ldconfig/ldconfig.c       29 Dec 2013 11:53:38 -0000
@@ -416,16 +416,16 @@ buildhints(void)
        if (write(fd, &hdr, sizeof(struct hints_header)) !=
            sizeof(struct hints_header)) {
                warn("%s", _PATH_LD_HINTS);
-               goto out;
+               goto fdout;
        }
        if (write(fd, blist, hdr.hh_nbucket * sizeof(struct hints_bucket)) !=
            hdr.hh_nbucket * sizeof(struct hints_bucket)) {
                warn("%s", _PATH_LD_HINTS);
-               goto out;
+               goto fdout;
        }
        if (write(fd, strtab, strtab_sz) != strtab_sz) {
                warn("%s", _PATH_LD_HINTS);
-               goto out;
+               goto fdout;
        }
        if (close(fd) != 0) {
                warn("%s", _PATH_LD_HINTS);
@@ -438,6 +438,8 @@ buildhints(void)
        }
 
        ret = 0;
+fdout:
+       (void)close(fd);
 out:
        free(blist);
        free(strtab);

Reply via email to