{
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;