diff options
author | Andrew Bartlett <abartlet@samba.org> | 2012-04-16 13:36:01 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2012-04-18 12:04:59 +1000 |
commit | 235016bcf9c332f88d3aae68d0726d8bb2a64246 (patch) | |
tree | 83d8ec9a01596e8b256134e0ee11def15967e5e0 /source3/lib | |
parent | 99caee5eef6e054ad6c94a00e3de869f764954f7 (diff) | |
download | samba-235016bcf9c332f88d3aae68d0726d8bb2a64246.tar.gz samba-235016bcf9c332f88d3aae68d0726d8bb2a64246.tar.bz2 samba-235016bcf9c332f88d3aae68d0726d8bb2a64246.zip |
s3-dbwrap: Add talloc_stackframe() calls
This is in preperation for calling dbwrap from common code, where we may not
have a stackframe set up.
Andrew Bartlett
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/dbwrap/dbwrap.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/source3/lib/dbwrap/dbwrap.c b/source3/lib/dbwrap/dbwrap.c index cfd15a976b..80bd09bf43 100644 --- a/source3/lib/dbwrap/dbwrap.c +++ b/source3/lib/dbwrap/dbwrap.c @@ -148,17 +148,23 @@ static struct db_record *dbwrap_fetch_locked_internal( { struct db_record *rec; struct dbwrap_lock_order_state *lock_order; + TALLOC_CTX *frame = talloc_stackframe(); + if (!frame) { + return NULL; + } - lock_order = dbwrap_check_lock_order(db, talloc_tos()); + lock_order = dbwrap_check_lock_order(db, frame); if (lock_order == NULL) { + TALLOC_FREE(frame); return NULL; } rec = db_fn(db, mem_ctx, key); if (rec == NULL) { - TALLOC_FREE(lock_order); + TALLOC_FREE(frame); return NULL; } (void)talloc_steal(rec, lock_order); + TALLOC_FREE(frame); return rec; } @@ -235,14 +241,19 @@ NTSTATUS dbwrap_store(struct db_context *db, TDB_DATA key, { struct db_record *rec; NTSTATUS status; + TALLOC_CTX *frame = talloc_stackframe(); + if (!frame) { + return NT_STATUS_NO_MEMORY; + } - rec = dbwrap_fetch_locked(db, talloc_tos(), key); + rec = dbwrap_fetch_locked(db, frame, key); if (rec == NULL) { + TALLOC_FREE(frame); return NT_STATUS_NO_MEMORY; } status = dbwrap_record_store(rec, data, flags); - TALLOC_FREE(rec); + TALLOC_FREE(frame); return status; } @@ -250,13 +261,18 @@ NTSTATUS dbwrap_delete(struct db_context *db, TDB_DATA key) { struct db_record *rec; NTSTATUS status; + TALLOC_CTX *frame = talloc_stackframe(); + if (!frame) { + return NT_STATUS_NO_MEMORY; + } rec = dbwrap_fetch_locked(db, talloc_tos(), key); if (rec == NULL) { + TALLOC_FREE(frame); return NT_STATUS_NO_MEMORY; } status = dbwrap_record_delete(rec); - TALLOC_FREE(rec); + TALLOC_FREE(frame); return status; } |