[PATCH 18/27] g_lock: don't leak lock_path onto talloc tos
David Disseldorp
ddiss at samba.org
Sun Nov 2 12:21:40 MST 2014
Also check for allocation failures.
Signed-off-by: David Disseldorp <ddiss at samba.org>
---
source3/lib/g_lock.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index 6813f06..30c5f52 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);
--
1.8.4.5
More information about the samba-technical
mailing list