summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-09-15 14:27:50 +1000
committerMichael Adam <obnox@samba.org>2008-09-29 14:01:00 +0200
commitacf5f2e5b049f20049cb6c549a00ba4b95322aa0 (patch)
treeee5962743ec37d69c9a0802f6625fa77e8dcc5d0
parenta93dc2c8589428e409fca5a6c21db50db001fe92 (diff)
downloadsamba-acf5f2e5b049f20049cb6c549a00ba4b95322aa0.tar.gz
samba-acf5f2e5b049f20049cb6c549a00ba4b95322aa0.tar.bz2
samba-acf5f2e5b049f20049cb6c549a00ba4b95322aa0.zip
fixed a segfault on the ctdb destructor code
-rw-r--r--source3/lib/dbwrap_ctdb.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c
index 63a5ce4de6..cd37d9e917 100644
--- a/source3/lib/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap_ctdb.c
@@ -405,8 +405,9 @@ static struct db_record *db_ctdb_fetch_locked_transaction(struct db_ctdb_ctx *ct
return result;
}
-static int db_ctdb_record_destructor(struct db_record *rec)
+static int db_ctdb_record_destructor(struct db_record **recp)
{
+ struct db_record *rec = talloc_get_type_abort(*recp, struct db_record);
struct db_ctdb_transaction_handle *h = talloc_get_type_abort(
rec->private_data, struct db_ctdb_transaction_handle);
int ret = h->ctx->db->transaction_commit(h->ctx->db);
@@ -424,7 +425,7 @@ static struct db_record *db_ctdb_fetch_locked_persistent(struct db_ctdb_ctx *ctx
TDB_DATA key)
{
int res;
- struct db_record *rec;
+ struct db_record *rec, **recp;
res = db_ctdb_transaction_start(ctx->db);
if (res == -1) {
@@ -438,7 +439,13 @@ static struct db_record *db_ctdb_fetch_locked_persistent(struct db_ctdb_ctx *ctx
}
/* destroy this transaction when we release the lock */
- talloc_set_destructor((struct db_record *)talloc_new(rec), db_ctdb_record_destructor);
+ recp = talloc(rec, struct db_record *);
+ if (recp == NULL) {
+ ctx->db->transaction_cancel(ctx->db);
+ return NULL;
+ }
+ *recp = rec;
+ talloc_set_destructor(recp, db_ctdb_record_destructor);
return rec;
}