mirror of
https://github.com/samba-team/samba.git
synced 2025-08-26 01:49:31 +03:00
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>
This commit is contained in:
committed by
Jeremy Allison
parent
176259f2c4
commit
d9d16cb582
@ -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);
|
||||
|
Reference in New Issue
Block a user