s4-registry: Don't leak file descriptor.
authorAndreas Schneider <asn@samba.org>
Wed, 20 Feb 2013 09:10:15 +0000 (10:10 +0100)
committerAlexander Bokovoy <ab@samba.org>
Fri, 22 Feb 2013 15:36:14 +0000 (16:36 +0100)
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source4/lib/registry/hive.c

index dc38fc82152f17fe93c4d75e8c9d13a8e16f08db..d79135fadba930076776edbc5b91d65a8961579d 100644 (file)
@@ -43,15 +43,14 @@ _PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
        }
 
        num = read(fd, peek, 20);
+       close(fd);
        if (num == -1) {
                return WERR_BADFILE;
        }
 
        if (!strncmp(peek, "regf", 4)) {
-               close(fd);
                return reg_open_regf_file(parent_ctx, location, root);
        } else if (!strncmp(peek, "TDB file", 8)) {
-               close(fd);
                return reg_open_ldb_file(parent_ctx, location, session_info,
                                         credentials, ev_ctx, lp_ctx, root);
        }