From: Amitay Isaacs Date: Thu, 4 Aug 2016 05:41:57 +0000 (+1000) Subject: ctdb-tools: Fix CID 1364701 - resource leak X-Git-Tag: tevent-0.9.30~217 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25f27e16b26e2c96a35dd7b42d22d16d63be6037;p=thirdparty%2Fsamba.git ctdb-tools: Fix CID 1364701 - resource leak BUG: https://bugzilla.samba.org/show_bug.cgi?id=12121 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index bbe07764e0f..085a84fb084 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -5362,7 +5362,7 @@ static int control_ptrans(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, db_flags, &db); if (ret != 0) { fprintf(stderr, "Failed to attach to DB %s\n", db_name); - return ret; + goto done; } ret = ctdb_transaction_start(mem_ctx, ctdb->ev, ctdb->client, @@ -5370,7 +5370,7 @@ static int control_ptrans(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, if (ret != 0) { fprintf(stderr, "Failed to start transaction on db %s\n", db_name); - return ret; + goto done; } while (ptrans_get_key_value(mem_ctx, file, &key, &value)) { @@ -5379,7 +5379,7 @@ static int control_ptrans(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, if (ret != 0) { fprintf(stderr, "Failed to store record\n"); ctdb_transaction_cancel(h); - return 1; + goto done; } talloc_free(key.dptr); talloc_free(value.dptr); @@ -5390,14 +5390,13 @@ static int control_ptrans(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, if (ret != 0) { fprintf(stderr, "Failed to commit transaction on db %s\n", db_name); - return ret; } +done: if (file != stdin) { fclose(file); } - - return 0; + return ret; } static int control_tfetch(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,