From: Andrew Bartlett Date: Mon, 17 May 2010 09:08:19 +0000 (+1000) Subject: s4:s3compat Avoid talloc_free() with references X-Git-Url: http://git.samba.org/?p=abartlet%2Fsamba.git%2F.git;a=commitdiff_plain;h=fc5b78bf58b557e0cbd0eb3a2a32e85779eb27ee s4:s3compat Avoid talloc_free() with references The ldb context is referenced, so free via a parent. Andrew Bartlett --- diff --git a/source4/s3compat/machine_sid.c b/source4/s3compat/machine_sid.c index 947530cf897..8291b759e9a 100644 --- a/source4/s3compat/machine_sid.c +++ b/source4/s3compat/machine_sid.c @@ -33,23 +33,31 @@ struct dom_sid *get_global_sam_sid(void) { const struct dom_sid *tmp_dom_sid; struct ldb_context *samdb; + TALLOC_CTX *tmp_ctx; if (global_sam_sid) { return global_sam_sid; } - samdb = samdb_connect(NULL, s3compat_get_tevent_ctx(), + tmp_ctx = talloc_new(NULL); + if (!tmp_ctx) { + return NULL; + } + + samdb = samdb_connect(tmp_ctx, s3compat_get_tevent_ctx(), s3compat_get_lp_ctx(), system_session(s3compat_get_lp_ctx())); if (!samdb) { DEBUG(0, ("Failed to open samdb to return global_sam_sid\n")); + talloc_free(tmp_ctx); return NULL; } tmp_dom_sid = samdb_domain_sid(samdb); if (!tmp_dom_sid) { DEBUG(0, ("Failed to obtain domain sid from samdb to return global_sam_sid\n")); + talloc_free(tmp_ctx); return NULL; } global_sam_sid = dom_sid_dup(talloc_autofree_context(), tmp_dom_sid); - talloc_free(samdb); + talloc_free(tmp_ctx); if (!global_sam_sid) { DEBUG(0, ("Failed to duplicate domain sid to return global_sam_sid\n")); return NULL;