[PATCH 19/27] server_mutex: don't leak lock_path onto talloc tos
David Disseldorp
ddiss at samba.org
Sun Nov 2 12:21:41 MST 2014
Also check for allocation failures.
Signed-off-by: David Disseldorp <ddiss at samba.org>
---
source3/lib/server_mutex.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/source3/lib/server_mutex.c b/source3/lib/server_mutex.c
index 43cf77b..56673f6 100644
--- a/source3/lib/server_mutex.c
+++ b/source3/lib/server_mutex.c
@@ -48,7 +48,7 @@ struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
{
struct named_mutex *result;
struct loadparm_context *lp_ctx;
- const char *fname;
+ char *fname;
result = talloc(mem_ctx, struct named_mutex);
if (result == NULL) {
@@ -71,6 +71,10 @@ struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
}
fname = lock_path("mutex.tdb");
+ if (fname == NULL) {
+ TALLOC_FREE(result);
+ return NULL;
+ }
result->tdb = tdb_wrap_open(result, fname,
lpcfg_tdb_hash_size(lp_ctx, fname),
@@ -79,6 +83,7 @@ struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
TDB_CLEAR_IF_FIRST |
TDB_INCOMPATIBLE_HASH),
O_RDWR|O_CREAT, 0600);
+ TALLOC_FREE(fname);
talloc_unlink(result, lp_ctx);
if (result->tdb == NULL) {
DEBUG(1, ("Could not open mutex.tdb: %s\n",
--
1.8.4.5
More information about the samba-technical
mailing list