]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:dsdb: Fix leaks
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Tue, 9 May 2023 04:11:37 +0000 (16:11 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 16 May 2023 23:29:32 +0000 (23:29 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/common/util_samr.c

index cf39b35846c12aa915eb28322c73cb0411760d9b..0a48fcf5b92221ff68fdc3c2bd59cfefd50cd072 100644 (file)
@@ -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;
        }