mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
ctdb-tools: Close tdb database on error
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 c9750c821e06364cb4559f857c359c14e6799303)
This commit is contained in:
parent
cab7216de2
commit
661f901109
@ -5442,17 +5442,20 @@ static int control_tfetch(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
|
||||
ret = str_to_data(argv[1], strlen(argv[1]), mem_ctx, &key);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Failed to parse key %s\n", argv[1]);
|
||||
tdb_close(tdb);
|
||||
return ret;
|
||||
}
|
||||
|
||||
data = tdb_fetch(tdb, key);
|
||||
if (data.dptr == NULL) {
|
||||
fprintf(stderr, "No record for key %s\n", argv[1]);
|
||||
tdb_close(tdb);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (data.dsize < sizeof(struct ctdb_ltdb_header)) {
|
||||
fprintf(stderr, "Invalid record for key %s\n", argv[1]);
|
||||
tdb_close(tdb);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -5514,12 +5517,14 @@ static int control_tstore(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
|
||||
ret = str_to_data(argv[1], strlen(argv[1]), mem_ctx, &key);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Failed to parse key %s\n", argv[1]);
|
||||
tdb_close(tdb);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = str_to_data(argv[2], strlen(argv[2]), mem_ctx, &value);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Failed to parse value %s\n", argv[2]);
|
||||
tdb_close(tdb);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -5540,6 +5545,7 @@ static int control_tstore(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
|
||||
data.dptr = talloc_size(mem_ctx, data.dsize);
|
||||
if (data.dptr == NULL) {
|
||||
fprintf(stderr, "Memory allocation error\n");
|
||||
tdb_close(tdb);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user