s4:torture: Fix leaks
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 16 Oct 2023 06:10:56 +0000 (19:10 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 19 Oct 2023 21:37:36 +0000 (21:37 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/torture/rpc/backupkey.c

index 8b7c6c30d105a8f214d40e57e391fb61b31594af..49c22f7d5b65eb91965e55e984a928e50a3ce43e 100644 (file)
@@ -276,11 +276,13 @@ static DATA_BLOB *create_access_check(struct torture_context *tctx,
 
        sid = get_user_sid(tctx, tmp_ctx, user);
        if (sid == NULL) {
+               talloc_free(tmp_ctx);
                return NULL;
        }
 
        blob = talloc_zero(mem_ctx, DATA_BLOB);
        if (blob == NULL) {
+               talloc_free(tmp_ctx);
                return NULL;
        }
 
@@ -298,6 +300,8 @@ static DATA_BLOB *create_access_check(struct torture_context *tctx,
                ndr_err = ndr_push_struct_blob(blob, blob, &access_struct,
                                (ndr_push_flags_fn_t)ndr_push_bkrp_access_check_v2);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+                       talloc_free(blob);
+                       talloc_free(tmp_ctx);
                        return NULL;
                }
 
@@ -334,6 +338,8 @@ static DATA_BLOB *create_access_check(struct torture_context *tctx,
                ndr_err = ndr_push_struct_blob(blob, blob, &access_struct,
                                (ndr_push_flags_fn_t)ndr_push_bkrp_access_check_v3);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+                       talloc_free(blob);
+                       talloc_free(tmp_ctx);
                        return NULL;
                }