summaryrefslogtreecommitdiffstats
path: root/source3/lib/server_mutex.c
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2014-11-02 20:21:41 +0100
committerJeremy Allison <jra@samba.org>2014-11-03 23:46:05 +0100
commit76fe51cea27ac29c5de237850795be7122ffdc12 (patch)
tree59a7d99101f44b20303bc231db344adf6d5083ba /source3/lib/server_mutex.c
parentd9d16cb582caa34154fef1ad1ff84265fc4eaea4 (diff)
downloadsamba-76fe51cea27ac29c5de237850795be7122ffdc12.tar.gz
samba-76fe51cea27ac29c5de237850795be7122ffdc12.tar.xz
samba-76fe51cea27ac29c5de237850795be7122ffdc12.zip
server_mutex: 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>
Diffstat (limited to 'source3/lib/server_mutex.c')
-rw-r--r--source3/lib/server_mutex.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/source3/lib/server_mutex.c b/source3/lib/server_mutex.c
index 43cf77b94d..56673f6863 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",