ctdb-tools: Fix CID 1364702 - resource leak
authorAmitay Isaacs <amitay@gmail.com>
Thu, 4 Aug 2016 05:46:33 +0000 (15:46 +1000)
committerMartin Schwenke <martins@samba.org>
Mon, 8 Aug 2016 06:17:33 +0000 (08:17 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12121

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/tools/ctdb.c

index 085a84fb08480959c18304d90458a7a7f8b13459..c3003926a4e5055efcc3deb11cf75134d099fbe1 100644 (file)
@@ -5450,11 +5450,13 @@ static int control_tfetch(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
                nwritten = sys_write(fd, data.dptr, data.dsize);
                if (nwritten != data.dsize) {
                        fprintf(stderr, "Failed to write record to file\n");
+                       close(fd);
                        goto fail;
                }
 
                close(fd);
        }
+
 fail:
        ret = ctdb_ltdb_header_extract(&data, &header);
        if (ret != 0) {