From: Joseph Sutton Date: Tue, 9 May 2023 04:11:37 +0000 (+1200) Subject: s4:dsdb: Fix leaks X-Git-Tag: talloc-2.4.1~680 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92ad2c7b9b9e0b7d49ccbb9bf18b3e5dfed2d299;p=thirdparty%2Fsamba.git s4:dsdb: Fix leaks Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/source4/dsdb/common/util_samr.c b/source4/dsdb/common/util_samr.c index cf39b35846c..0a48fcf5b92 100644 --- a/source4/dsdb/common/util_samr.c +++ b/source4/dsdb/common/util_samr.c @@ -291,11 +291,13 @@ NTSTATUS dsdb_add_domain_group(struct ldb_context *ldb, "(&(sAMAccountName=%s)(objectclass=group))", groupname_encoded); if (name != NULL) { + talloc_free(tmp_ctx); return NT_STATUS_GROUP_EXISTS; } msg = ldb_msg_new(tmp_ctx); if (msg == NULL) { + talloc_free(tmp_ctx); return NT_STATUS_NO_MEMORY; } @@ -338,6 +340,7 @@ NTSTATUS dsdb_add_domain_group(struct ldb_context *ldb, group_sid = samdb_search_dom_sid(ldb, tmp_ctx, msg->dn, "objectSid", NULL); if (group_sid == NULL) { + talloc_free(tmp_ctx); return NT_STATUS_UNSUCCESSFUL; } @@ -369,6 +372,7 @@ NTSTATUS dsdb_add_domain_alias(struct ldb_context *ldb, if (ldb_transaction_start(ldb) != LDB_SUCCESS) { DEBUG(0, ("Failed to start transaction in dsdb_add_domain_alias(): %s\n", ldb_errstring(ldb))); + talloc_free(tmp_ctx); return NT_STATUS_INTERNAL_ERROR; } @@ -433,6 +437,7 @@ NTSTATUS dsdb_add_domain_alias(struct ldb_context *ldb, if (ldb_transaction_commit(ldb) != LDB_SUCCESS) { DEBUG(0, ("Failed to commit transaction in dsdb_add_domain_alias(): %s\n", ldb_errstring(ldb))); + talloc_free(tmp_ctx); return NT_STATUS_INTERNAL_ERROR; }