]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tools: Fix CID 1364706 - resource leak
authorAmitay Isaacs <amitay@gmail.com>
Thu, 4 Aug 2016 05:58:34 +0000 (15:58 +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 cbcdea19ff995d95b76acd12d3dc942bb2e78c0c..790170befd5117aefc42553df845c5052853b063 100644 (file)
@@ -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;
 }