summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2014-11-02 20:21:40 +0100
committerJeremy Allison <jra@samba.org>2014-11-03 23:46:05 +0100
commitd9d16cb582caa34154fef1ad1ff84265fc4eaea4 (patch)
tree255f7bd6ca4533cc0d2fb4be82215a43ae56b1cd
parent176259f2c47d3a32dc105e211cc8097c60031dbf (diff)
downloadsamba-d9d16cb582caa34154fef1ad1ff84265fc4eaea4.tar.gz
samba-d9d16cb582caa34154fef1ad1ff84265fc4eaea4.tar.xz
samba-d9d16cb582caa34154fef1ad1ff84265fc4eaea4.zip
g_lock: don't leak lock_path onto talloc tos
Also check for allocation failures. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r--source3/lib/g_lock.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index 6813f0641f..30c5f52431 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -51,6 +51,7 @@ struct g_lock_ctx *g_lock_ctx_init(TALLOC_CTX *mem_ctx,
struct messaging_context *msg)
{
struct g_lock_ctx *result;
+ char *db_path;
result = talloc(mem_ctx, struct g_lock_ctx);
if (result == NULL) {
@@ -58,11 +59,18 @@ struct g_lock_ctx *g_lock_ctx_init(TALLOC_CTX *mem_ctx,
}
result->msg = msg;
- result->db = db_open(result, lock_path("g_lock.tdb"), 0,
+ db_path = lock_path("g_lock.tdb");
+ if (db_path == NULL) {
+ TALLOC_FREE(result);
+ return NULL;
+ }
+
+ result->db = db_open(result, db_path, 0,
TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
O_RDWR|O_CREAT, 0600,
DBWRAP_LOCK_ORDER_2,
DBWRAP_FLAG_NONE);
+ TALLOC_FREE(db_path);
if (result->db == NULL) {
DEBUG(1, ("g_lock_init: Could not open g_lock.tdb\n"));
TALLOC_FREE(result);