summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2016-08-04 15:58:34 +1000
committerStefan Metzmacher <metze@samba.org>2016-08-10 11:24:37 +0200
commitc1dfac0a2705a6f6243340c107d69d1eababbcff (patch)
tree73b0b2df79f47de2bbe612761c52d7e8d6058ea5
parent66bf88a6e501e410b7172af1ecd956df12edd999 (diff)
downloadsamba-c1dfac0a2705a6f6243340c107d69d1eababbcff.tar.gz
ctdb-tools: Fix CID 1364706 - resource leak
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> (cherry picked from commit bfe891e418fd372c1e7036f08e81b65c27843a79)
-rw-r--r--ctdb/tools/ctdb.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 6db57f4727f..da218aa1e35 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -4457,6 +4457,7 @@ static int control_dumpdbbackup(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
fprintf(stderr,
"Wrong version of backup file, expected %u, got %lu\n",
DB_VERSION, db_hdr.version);
+ close(fd);
return EINVAL;
}
@@ -4474,6 +4475,7 @@ static int control_dumpdbbackup(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
ret = ctdb_rec_buffer_read(fd, mem_ctx, &recbuf);
if (ret != 0) {
fprintf(stderr, "Failed to read records\n");
+ close(fd);
return ret;
}
@@ -4481,10 +4483,12 @@ static int control_dumpdbbackup(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
&state);
if (ret != 0) {
fprintf(stderr, "Failed to dump records\n");
+ close(fd);
return ret;
}
}
+ close(fd);
printf("Dumped %u record(s)\n", state.sub_state.count);
return 0;
}