From c1dfac0a2705a6f6243340c107d69d1eababbcff Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 4 Aug 2016 15:58:34 +1000 Subject: ctdb-tools: Fix CID 1364706 - resource leak BUG: https://bugzilla.samba.org/show_bug.cgi?id=12121 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke (cherry picked from commit bfe891e418fd372c1e7036f08e81b65c27843a79) --- ctdb/tools/ctdb.c | 4 ++++ 1 file changed, 4 insertions(+) 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; } -- cgit v1.2.1