]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: talloc_destroy() -> TALLOC_FREE()
authorVolker Lendecke <vl@samba.org>
Fri, 17 Oct 2025 12:39:18 +0000 (14:39 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 10 Nov 2025 13:29:30 +0000 (13:29 +0000)
Sweeping change, I know. Should not change compiled code in most
cases, the compiler should be smart enough to elide the assignment
right before a return. In the cases where this is not right before the
return, TALLOC_FREE() is safer as it makes use-after-free crash.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
30 files changed:
source3/include/smb_macros.h
source3/libads/ldap.c
source3/libads/ldap_user.c
source3/libsmb/cliquota.c
source3/locking/posix.c
source3/modules/vfs_afsacl.c
source3/passdb/pdb_ldap.c
source3/printing/nt_printing.c
source3/printing/nt_printing_tdb.c
source3/registry/regfio.c
source3/rpc_server/spoolss/srv_spoolss_nt.c
source3/rpcclient/cmd_samr.c
source3/rpcclient/cmd_spoolss.c
source3/smbd/ntquotas.c
source3/torture/torture.c
source3/torture/vfstest.c
source3/utils/net_ads.c
source3/utils/net_ads_gpo.c
source3/utils/net_groupmap.c
source3/utils/net_rpc.c
source3/utils/net_rpc_shell.c
source3/utils/net_rpc_trust.c
source3/utils/net_usershare.c
source3/utils/sharesec.c
source3/winbindd/idmap_ad_nss.c
source3/winbindd/winbindd_cache.c
source3/winbindd/winbindd_cm.c
source3/winbindd/winbindd_cred_cache.c
source3/winbindd/winbindd_dual.c
source3/winbindd/winbindd_util.c

index b29e8e4201a3638bb5ef1eb16a04ee5c8eadac2e..5a7da2f90de5c2e0f0ca2cfd6e74673e528ae5e6 100644 (file)
@@ -212,7 +212,6 @@ copy an IP address from one buffer to another
 #define SMB_XMALLOC_ARRAY(type,count) (type *)smb_xmalloc_array(sizeof(type),(count))
 
 #define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__)
-#define talloc_destroy(ctx) talloc_free(ctx)
 #ifndef TALLOC_FREE
 #define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
 #endif
index 862ac6e18e4cb6984936a0f550ad093988a7d4a0..c0974af59766f273b4f463af9f9db9c42a5d4a21 100644 (file)
@@ -1553,7 +1553,7 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads,
        ldap_controls_free(rcontrols);
 
 done:
-       talloc_destroy(ctx);
+       TALLOC_FREE(ctx);
 
        if (ext_be) {
                ber_free(ext_be, 1);
@@ -1766,7 +1766,7 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
        }
 
  done:
-       talloc_destroy(ctx);
+       TALLOC_FREE(ctx);
        /* if/when we decide to utf8-encode attrs, take out this next line */
        TALLOC_FREE(search_attrs);
        return ADS_ERROR(rc);
@@ -2402,7 +2402,7 @@ ADS_STATUS ads_clear_service_principal_names(ADS_STRUCT *ads, const char *machin
        }
 
        if (!(mods = ads_init_mods(ctx))) {
-               talloc_destroy(ctx);
+               TALLOC_FREE(ctx);
                ads_msgfree(ads, res);
                return ADS_ERROR(LDAP_NO_MEMORY);
        }
@@ -2410,12 +2410,12 @@ ADS_STATUS ads_clear_service_principal_names(ADS_STRUCT *ads, const char *machin
        if (!ADS_ERR_OK(ret)) {
                DEBUG(1,("ads_clear_service_principal_names: Error creating strlist.\n"));
                ads_msgfree(ads, res);
-               talloc_destroy(ctx);
+               TALLOC_FREE(ctx);
                return ret;
        }
        dn_string = ads_get_dn(ads, talloc_tos(), res);
        if (!dn_string) {
-               talloc_destroy(ctx);
+               TALLOC_FREE(ctx);
                ads_msgfree(ads, res);
                return ADS_ERROR(LDAP_NO_MEMORY);
        }
@@ -2425,12 +2425,12 @@ ADS_STATUS ads_clear_service_principal_names(ADS_STRUCT *ads, const char *machin
                DEBUG(1,("ads_clear_service_principal_names: Error: Updating Service Principals for machine %s in LDAP\n",
                        machine_name));
                ads_msgfree(ads, res);
-               talloc_destroy(ctx);
+               TALLOC_FREE(ctx);
                return ret;
        }
 
        ads_msgfree(ads, res);
-       talloc_destroy(ctx);
+       TALLOC_FREE(ctx);
        return ret;
 }
 
@@ -2903,7 +2903,7 @@ ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads,
 
 done:
        SAFE_FREE(machine_escaped);
-       talloc_destroy(ctx);
+       TALLOC_FREE(ctx);
 
        return ret;
 }
@@ -3199,7 +3199,7 @@ static bool ads_dump_field(ADS_STRUCT *ads, char *field, void **values, void *da
                fn(ads, NULL, NULL, data_area); /* completed an entry */
 
        }
-       talloc_destroy(ctx);
+       TALLOC_FREE(ctx);
 }
 
 /**
index 40c87c833d36b9cd7a523db0db0835bbcad47f4a..05558e9fe743255d8dd46ee9d6a7ae6532ec2972 100644 (file)
@@ -89,7 +89,7 @@ ADS_STATUS ads_add_user_acct(ADS_STRUCT *ads, const char *user,
 
  done:
        SAFE_FREE(name_escaped);
-       talloc_destroy(ctx);
+       TALLOC_FREE(ctx);
        return status;
 }
 
@@ -126,7 +126,7 @@ ADS_STATUS ads_add_group_acct(ADS_STRUCT *ads, const char *group,
 
  done:
        SAFE_FREE(name_escaped);
-       talloc_destroy(ctx);
+       TALLOC_FREE(ctx);
        return status;
 }
 #endif
index 865a41ff6188600defd5050c28016bda7a58ed50..544d1be67df0c63c0efd861ab412acc7a6da4963 100644 (file)
@@ -42,8 +42,7 @@ void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list)
                return;
        }
 
-       if ((*qt_list)->mem_ctx)
-               talloc_destroy((*qt_list)->mem_ctx);
+       TALLOC_FREE((*qt_list)->mem_ctx);
 
        (*qt_list) = NULL;
 
index e900132430dfbb717afe128d62bf1f64c0502485..b476869b7ee0bd1d80901fcd6f3cc33a4bcda351 100644 (file)
@@ -832,7 +832,7 @@ BECOMES.....
 
                                if(l_new == NULL) {
                                        DEBUG(0,("posix_lock_list: talloc fail.\n"));
-                                       return NULL; /* The talloc_destroy takes care of cleanup. */
+                                       return NULL; /* The TALLOC_FREE takes care of cleanup. */
                                }
 
                                ZERO_STRUCTP(l_new);
@@ -948,7 +948,7 @@ bool set_posix_lock_windows_flavour(files_struct *fsp,
 
        if ((ll = talloc(l_ctx, struct lock_list)) == NULL) {
                DEBUG(0,("set_posix_lock_windows_flavour: unable to talloc unlock list.\n"));
-               talloc_destroy(l_ctx);
+               TALLOC_FREE(l_ctx);
                return False;
        }
 
@@ -1028,7 +1028,7 @@ bool set_posix_lock_windows_flavour(files_struct *fsp,
                increment_lock_ref_count(fsp);
        }
 
-       talloc_destroy(l_ctx);
+       TALLOC_FREE(l_ctx);
        return ret;
 }
 
@@ -1077,7 +1077,7 @@ bool release_posix_lock_windows_flavour(files_struct *fsp,
 
        if ((ul = talloc(ul_ctx, struct lock_list)) == NULL) {
                DBG_ERR("unable to talloc unlock list.\n");
-               talloc_destroy(ul_ctx);
+               TALLOC_FREE(ul_ctx);
                return False;
        }
 
@@ -1126,7 +1126,7 @@ bool release_posix_lock_windows_flavour(files_struct *fsp,
                if (!posix_fcntl_lock(fsp,F_SETLK,offset,count,F_RDLCK)) {
                        DBG_ERR("downgrade of lock failed with error %s !\n",
                                strerror(errno));
-                       talloc_destroy(ul_ctx);
+                       TALLOC_FREE(ul_ctx);
                        return False;
                }
        }
@@ -1149,7 +1149,7 @@ bool release_posix_lock_windows_flavour(files_struct *fsp,
                }
        }
 
-       talloc_destroy(ul_ctx);
+       TALLOC_FREE(ul_ctx);
        return ret;
 }
 
@@ -1329,7 +1329,7 @@ bool release_posix_lock_posix_flavour(files_struct *fsp,
 
        if ((ul = talloc(ul_ctx, struct lock_list)) == NULL) {
                DEBUG(0,("release_posix_lock_windows_flavour: unable to talloc unlock list.\n"));
-               talloc_destroy(ul_ctx);
+               TALLOC_FREE(ul_ctx);
                return False;
        }
 
@@ -1375,6 +1375,6 @@ bool release_posix_lock_posix_flavour(files_struct *fsp,
        if (!locks_exist_on_context(plocks, num_locks, lock_ctx)) {
                decrement_posix_lock_count(fsp, lock_ctx->smblctx);
        }
-       talloc_destroy(ul_ctx);
+       TALLOC_FREE(ul_ctx);
        return ret;
 }
index 3dc80d3bddc7173fdeb86e72ecbae16ae72b1356..d2a75d563b14090a7f688db99447d5c146f30898 100644 (file)
@@ -83,9 +83,7 @@ static bool init_afs_acl(struct afs_acl *acl)
 
 static void free_afs_acl(struct afs_acl *acl)
 {
-       if (acl->ctx != NULL)
-               talloc_destroy(acl->ctx);
-       acl->ctx = NULL;
+       TALLOC_FREE(acl->ctx);
        acl->num_aces = 0;
        acl->acelist = NULL;
 }
index 73830d45fd6be5d466085096e6a785ab8baccdff..1d9fb80b3e2d0e3f68b920f6d2313ee8655b8d1f 100644 (file)
@@ -303,8 +303,7 @@ static NTSTATUS ldapsam_get_seq_num(struct pdb_methods *my_methods, time_t *seq_
                ldap_value_free(values);
        if (msg != NULL)
                ldap_msgfree(msg);
-       if (mem_ctx)
-               talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        return ntstatus;
 }
index 5b322c38baf227f98998f44c7b07a3af6ec96b53..81f5f53962b11f8489c25489c44e4590b1611e19 100644 (file)
@@ -2280,7 +2280,7 @@ WERROR print_access_check(const struct auth_session_info *session_info,
                                            pname,
                                            &secdesc);
        if (!W_ERROR_IS_OK(result)) {
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return WERR_NOT_ENOUGH_MEMORY;
        }
 
@@ -2298,7 +2298,7 @@ WERROR print_access_check(const struct auth_session_info *session_info,
                                                 parent_secdesc->group_sid,
                                                 false);
                if (!NT_STATUS_IS_OK(status)) {
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return ntstatus_to_werror(status);
                }
 
@@ -2313,7 +2313,7 @@ WERROR print_access_check(const struct auth_session_info *session_info,
 
        DEBUG(4, ("access check was %s\n", NT_STATUS_IS_OK(status) ? "SUCCESS" : "FAILURE"));
 
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        return ntstatus_to_werror(status);
 }
index eddefe59e7275d265e24958053620b8bf8a3cfa5..9702d27490b1c0fe8474fec55db3037f681c686c 100644 (file)
@@ -266,7 +266,7 @@ static bool upgrade_to_version_4(void)
 
        result = tdb_traverse( tdb_printers, sec_desc_upg_fn, ctx );
 
-       talloc_destroy( ctx );
+       TALLOC_FREE( ctx );
 
        return ( result >= 0 );
 }
@@ -334,7 +334,7 @@ static bool upgrade_to_version_5(void)
 
        result = tdb_traverse( tdb_printers, normalize_printers_fn, NULL );
 
-       talloc_destroy( ctx );
+       TALLOC_FREE( ctx );
 
        return ( result >= 0 );
 }
index a9b8ce8b7e4f5936571c645717bf1da409751d93..5eab4f6c21f63a909d6cdf1927d4f8a592e7ae6e 100644 (file)
@@ -1296,7 +1296,7 @@ static void regfio_mem_free( REGF_FILE *file )
        /* free any talloc()'d memory */
 
        if ( file && file->mem_ctx )
-               talloc_destroy( file->mem_ctx );
+               TALLOC_FREE( file->mem_ctx );
 }
 
 /*******************************************************************
index 696259a87bf92a6a6b28733bf33d6b9737e5d285..e80092bec89bc950cc70f404910ded89922fc59e 100644 (file)
@@ -990,7 +990,7 @@ static void notify_msg_ctr_destroy( SPOOLSS_NOTIFY_MSG_CTR *ctr )
                return;
 
        if ( ctr->ctx )
-               talloc_destroy(ctr->ctx);
+               TALLOC_FREE(ctr->ctx);
 
        ZERO_STRUCTP(ctr);
 
index 292483273c1161eb87d46f7cff42c8c88f5dfa50..042fbc52eff06a223521c2f40eaa0581242ddfe1 100644 (file)
@@ -2581,7 +2581,7 @@ static NTSTATUS cmd_samr_query_sec_obj(struct rpc_pipe_client *cli,
        if ((argc < 1) || (argc > 3)) {
                printf("Usage: %s [rid|-d] [sec_info]\n", argv[0]);
                printf("\tSpecify rid for security on user, -d for security on domain\n");
-               talloc_destroy(ctx);
+               TALLOC_FREE(ctx);
                return NT_STATUS_OK;
        }
 
@@ -2666,7 +2666,7 @@ static NTSTATUS cmd_samr_query_sec_obj(struct rpc_pipe_client *cli,
        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
 done:
-       talloc_destroy(ctx);
+       TALLOC_FREE(ctx);
        return status;
 }
 
index 53636608ef5e203e117dfc4a40a3d3b6fda35e82..0ea20854296bb14284004cb2304b3049bb1419c8 100644 (file)
@@ -3404,7 +3404,7 @@ static bool compare_printer( struct rpc_pipe_client *cli1, struct policy_handle
                                           &info1);
        if ( !W_ERROR_IS_OK(werror) ) {
                printf("failed (%s)\n", win_errstr(werror));
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return false;
        }
        printf("ok\n");
@@ -3417,12 +3417,12 @@ static bool compare_printer( struct rpc_pipe_client *cli1, struct policy_handle
                                           &info2);
        if ( !W_ERROR_IS_OK(werror) ) {
                printf("failed (%s)\n", win_errstr(werror));
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return false;
        }
        printf("ok\n");
 
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        return true;
 }
@@ -3487,7 +3487,7 @@ static bool compare_printer_secdesc( struct rpc_pipe_client *cli1, struct policy
        printf("Security descriptors match\n");
 
 done:
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
        return result;
 }
 
index dbbd2f7842cb16049e7409ab03625c4e1c407d15..d3e1949088532257a1a91a2fad2fe6648e2ae6d2 100644 (file)
@@ -216,14 +216,14 @@ int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list)
                if ((tmp_list_ent=talloc_zero(mem_ctx,SMB_NTQUOTA_LIST))==NULL) {
                        DEBUG(0,("TALLOC_ZERO() failed\n"));
                        *qt_list = NULL;
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return (-1);
                }
 
                if ((tmp_list_ent->quotas=talloc_zero(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) {
                        DEBUG(0,("TALLOC_ZERO() failed\n"));
                        *qt_list = NULL;
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return (-1);
                }
 
index a9822381b260b3bae7462638cff8967bf72d44cd..afb0ba52ebcf3c64f67f63a1667a23ffc901c1a9 100644 (file)
@@ -10261,7 +10261,7 @@ static bool run_eatest(int dummy)
        printf("starting eatest\n");
 
        if (!torture_open_connection(&cli, 0)) {
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return False;
        }
 
@@ -10273,7 +10273,7 @@ static bool run_eatest(int dummy)
                               0x4044, 0, &fnum, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open failed - %s\n", nt_errstr(status));
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return False;
        }
 
@@ -10286,7 +10286,7 @@ static bool run_eatest(int dummy)
                if (!NT_STATUS_IS_OK(status)) {
                        printf("ea_set of name %s failed - %s\n", ea_name,
                               nt_errstr(status));
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return False;
                }
        }
@@ -10301,7 +10301,7 @@ static bool run_eatest(int dummy)
                if (!NT_STATUS_IS_OK(status)) {
                        printf("ea_set of name %s failed - %s\n", ea_name,
                               nt_errstr(status));
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return False;
                }
        }
@@ -10338,7 +10338,7 @@ static bool run_eatest(int dummy)
                if (!NT_STATUS_IS_OK(status)) {
                        printf("ea_set of name %s failed - %s\n", ea_name,
                               nt_errstr(status));
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return False;
                }
        }
@@ -10370,7 +10370,7 @@ static bool run_eatest(int dummy)
                correct = False;
        }
 
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
        if (!torture_close_connection(cli)) {
                correct = False;
        }
index b25dfdc41d5089fa41c85149fc847a3402fcefdc..6d96b8ec5331d1bf124faf8bae918be408a77612 100644 (file)
@@ -218,8 +218,7 @@ static NTSTATUS cmd_debuglevel(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a
 static NTSTATUS cmd_freemem(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
 {
        /* Cleanup */
-       talloc_destroy(mem_ctx);
-       mem_ctx = NULL;
+       TALLOC_FREE(mem_ctx);
        vfs->data = NULL;
        vfs->data_size = 0;
        return NT_STATUS_OK;
@@ -228,7 +227,7 @@ static NTSTATUS cmd_freemem(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc
 static NTSTATUS cmd_quit(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
 {
        /* Cleanup */
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        exit(0);
        return NT_STATUS_OK; /* NOTREACHED */
index d49b7537e716b4f269b92c0ad8ca3609c0abf8cd..a335517c544e5f96bd15070ef5ecff1b8049ba16 100644 (file)
@@ -2420,7 +2420,7 @@ static int net_ads_printer_publish(struct net_context *c,
 
        ret = 0;
 out:
-       talloc_destroy(tmp_ctx);
+       TALLOC_FREE(tmp_ctx);
 
        return ret;
 }
index 12d8e22d9725420bc255c47b87d48e3718581fea..ed80f049200a450c1da126a1ccae9ae74dde7042 100644 (file)
@@ -176,7 +176,7 @@ static int net_ads_gpo_list(struct net_context *c, int argc, const char **argv)
 out:
        ads_msgfree(ads, res);
 
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        return 0;
 }
@@ -217,7 +217,7 @@ static int net_ads_gpo_link_get(struct net_context *c, int argc, const char **ar
        dump_gplink(&gp_link);
 
 out:
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        return 0;
 }
@@ -262,7 +262,7 @@ static int net_ads_gpo_link_add(struct net_context *c, int argc, const char **ar
        }
 
 out:
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        return 0;
 }
@@ -301,7 +301,7 @@ static int net_ads_gpo_link_delete(struct net_context *c, int argc, const char *
        }
 
 out:
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        return 0;
 }
@@ -361,7 +361,7 @@ static int net_ads_gpo_get_gpo(struct net_context *c, int argc, const char **arg
        dump_gpo(&gpo, 0);
 
 out:
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        return 0;
 }
index 4f36d450f8ef3dc890fe804240fe7c5ea71bb339..854cf40e3f98216a0486825dfb1a680d5907b631 100644 (file)
@@ -924,7 +924,7 @@ static int net_groupmap_memberships(struct net_context *c, int argc, const char
            !print_alias_memberships(mem_ctx, &global_sid_Builtin, &member))
                return -1;
 
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        return 0;
 }
index 20aa01da90f27e5b5f3f2c4254a0f366e7ab2f5e..99dde46bec54fbb0d8d35dd8105a2908fb1574d9 100644 (file)
@@ -254,7 +254,7 @@ fail:
                cli_shutdown(cli);
        }
 
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
        return ret;
 }
 
@@ -509,7 +509,7 @@ int net_rpc_testjoin(struct net_context *c, int argc, const char **argv)
                if (!c->msg_ctx) {
                        d_fprintf(stderr, _("Could not initialise message context. "
                                "Try running as root\n"));
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return -1;
                }
 
@@ -539,7 +539,7 @@ int net_rpc_testjoin(struct net_context *c, int argc, const char **argv)
                                             &info);
                }
                if (!NT_STATUS_IS_OK(status)) {
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return -1;
                }
 
@@ -554,12 +554,12 @@ int net_rpc_testjoin(struct net_context *c, int argc, const char **argv)
        if (!NT_STATUS_IS_OK(status)) {
                fprintf(stderr,"Join to domain '%s' is not valid: %s\n",
                        domain, nt_errstr(status));
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        }
 
        printf("Join to '%s' is OK\n",domain);
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        return 0;
 }
@@ -6923,7 +6923,7 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("Couldn't connect to domain controller: %s\n",
                          nt_errstr(nt_status)));
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        };
 
@@ -6933,7 +6933,7 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
                DEBUG(0, ("Could not initialise lsa pipe. Error was %s\n",
                        nt_errstr(nt_status) ));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        };
 
@@ -6967,14 +6967,14 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
                DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
                        nt_errstr(nt_status)));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        }
        if (NT_STATUS_IS_ERR(result)) {
                DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
                        nt_errstr(result)));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        }
 
@@ -6998,7 +6998,7 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
                        DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n",
                                nt_errstr(nt_status)));
                        cli_shutdown(cli);
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return -1;
                };
                if (NT_STATUS_IS_ERR(result)) {
@@ -7006,7 +7006,7 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
                        DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n",
                                nt_errstr(result)));
                        cli_shutdown(cli);
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return -1;
                };
 
@@ -7021,7 +7021,7 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
                                                           dom_list.domains[i].name.string);
                        if (!NT_STATUS_IS_OK(nt_status)) {
                                cli_shutdown(cli);
-                               talloc_destroy(mem_ctx);
+                               TALLOC_FREE(mem_ctx);
                                return -1;
                        }
                };
@@ -7040,14 +7040,14 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
                DEBUG(0, ("Couldn't properly close lsa policy handle. Error was %s\n",
                        nt_errstr(nt_status)));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        };
 
        /* close lsarpc pipe and connection to IPC$ */
        cli_shutdown(cli);
 
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
        return 0;
 }
 
@@ -7116,7 +7116,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("Couldn't connect to domain controller: %s\n",
                          nt_errstr(nt_status)));
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        };
 
@@ -7126,7 +7126,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                DEBUG(0, ("Could not initialise lsa pipe. Error was %s\n",
                        nt_errstr(nt_status) ));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        };
 
@@ -7160,14 +7160,14 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
                        nt_errstr(nt_status)));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        }
        if (NT_STATUS_IS_ERR(result)) {
                DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
                        nt_errstr(result)));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        }
 
@@ -7193,14 +7193,14 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                        DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n",
                                nt_errstr(nt_status)));
                        cli_shutdown(cli);
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return -1;
                };
                if (NT_STATUS_IS_ERR(result)) {
                        DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n",
                                nt_errstr(result)));
                        cli_shutdown(cli);
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return -1;
                };
 
@@ -7228,7 +7228,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                DEBUG(0, ("Couldn't properly close lsa policy handle. Error was %s\n",
                        nt_errstr(nt_status)));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        };
 
@@ -7248,7 +7248,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("Could not initialise samr pipe. Error was %s\n", nt_errstr(nt_status)));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        };
 
@@ -7264,7 +7264,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                DEBUG(0, ("Couldn't open SAMR policy handle. Error was %s\n",
                        nt_errstr(nt_status)));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        };
        if (!NT_STATUS_IS_OK(result)) {
@@ -7272,7 +7272,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                DEBUG(0, ("Couldn't open SAMR policy handle. Error was %s\n",
                        nt_errstr(result)));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        };
 
@@ -7288,7 +7288,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                DEBUG(0, ("Couldn't open domain object. Error was %s\n",
                        nt_errstr(nt_status)));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        };
        if (!NT_STATUS_IS_OK(result)) {
@@ -7296,7 +7296,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                DEBUG(0, ("Couldn't open domain object. Error was %s\n",
                        nt_errstr(result)));
                cli_shutdown(cli);
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return -1;
        };
 
@@ -7321,7 +7321,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                        DEBUG(0, ("Couldn't enumerate accounts. Error was: %s\n",
                                nt_errstr(nt_status)));
                        cli_shutdown(cli);
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return -1;
                };
                if (NT_STATUS_IS_ERR(result)) {
@@ -7329,7 +7329,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                        DEBUG(0, ("Couldn't enumerate accounts. Error was: %s\n",
                                nt_errstr(result)));
                        cli_shutdown(cli);
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return -1;
                };
 
@@ -7353,7 +7353,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                        /* set opt_* variables to remote domain */
                        if (!strupper_m(str)) {
                                cli_shutdown(cli);
-                               talloc_destroy(mem_ctx);
+                               TALLOC_FREE(mem_ctx);
                                return -1;
                        }
                        c->opt_workgroup = talloc_strdup(mem_ctx, str);
@@ -7404,7 +7404,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
        /* close samr pipe and connection to IPC$ */
        cli_shutdown(cli);
 
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
        return 0;
 }
 
index f50233146b9a80bcd04980851e6d084bf80ae724..577c6661492e116642f0736d077ae2f1045ee39b 100644 (file)
@@ -100,7 +100,7 @@ static NTSTATUS net_sh_run(struct net_context *c,
 
        TALLOC_FREE(pipe_hnd);
 
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 
        return status;
 }
index ef10bb4c078d7a5a7a444f7dda43422e214b30d7..7b33e2cc89f866f19ef975df661c28e4c696116d 100644 (file)
@@ -695,7 +695,7 @@ done:
        data_blob_clear_free(&session_key[1]);
        cli_shutdown(cli[0]);
        cli_shutdown(cli[1]);
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
        return success;
 }
 
index 745888224348bf422db16c588c88b947f1567e88..bbb3283c5363227d73d545fb75eeb7176b9a982d 100644 (file)
@@ -546,7 +546,7 @@ static int net_usershare_info(struct net_context *c, int argc, const char **argv
        pi.c = c;
 
        ret = process_share_list(info_fn, &pi);
-       talloc_destroy(ctx);
+       TALLOC_FREE(ctx);
        return ret;
 }
 
@@ -1091,7 +1091,7 @@ static int net_usershare_list(struct net_context *c, int argc,
        pi.c = c;
 
        ret = process_share_list(info_fn, &pi);
-       talloc_destroy(ctx);
+       TALLOC_FREE(ctx);
        return ret;
 }
 
index 47182894a66890325c4c2deb24f784f78156b185..ea7c56e65667993903c71dd928ae286d7ca4964b 100644 (file)
@@ -683,7 +683,7 @@ int main(int argc, const char *argv[])
 done:
        gfree_all();
        poptFreeContext(pc);
-       talloc_destroy(ctx);
+       TALLOC_FREE(ctx);
 
        return retval;
 }
index 31202806214626b46d0c7893f99c95913a9df42f..c44149f906411ada69cd25f1bb6317a57582cd04 100644 (file)
@@ -264,9 +264,7 @@ static NTSTATUS nss_ad_map_to_alias(TALLOC_CTX *mem_ctx,
        nt_status = NT_STATUS_OK;
 
 done:
-       if (filter) {
-               talloc_destroy(filter);
-       }
+       TALLOC_FREE(filter);
        if (msg) {
                ads_msgfree(ctx->ads, msg);
        }
index 65a5ae17596b4476750df9c9b908e268cbf1a16f..eb79586a2ca6108c8af5a5440fbfff55a06f1602 100644 (file)
@@ -4131,7 +4131,7 @@ static int cache_traverse_validate_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_D
                                                          v_state);
 
                        SAFE_FREE(keystr);
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return ret;
                }
        }
index 3963881ca4540df29722ea4a5a92f595b93baab8..67003bb00fb3617b2ad019ba6e91850d46039220 100644 (file)
@@ -1777,7 +1777,7 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain,
        }
 
 out:
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
        return result;
 }
 
index b250daeac787ec0537bd9b9e574311c11d13ef2f..04f04510d330c2ab927092b7085f7bb2ff6580da 100644 (file)
@@ -948,13 +948,13 @@ static NTSTATUS winbindd_add_memory_creds_internal(const char *username,
        }
        memcredp->username = talloc_strdup(memcredp, username);
        if (!memcredp->username) {
-               talloc_destroy(memcredp);
+               TALLOC_FREE(memcredp);
                return NT_STATUS_NO_MEMORY;
        }
 
        status = store_memory_creds(memcredp, pass);
        if (!NT_STATUS_IS_OK(status)) {
-               talloc_destroy(memcredp);
+               TALLOC_FREE(memcredp);
                return status;
        }
 
@@ -1029,7 +1029,7 @@ NTSTATUS winbindd_delete_memory_creds(const char *username)
        if (memcredp->ref_count <= 0) {
                delete_memory_creds(memcredp);
                DLIST_REMOVE(memory_creds_list, memcredp);
-               talloc_destroy(memcredp);
+               TALLOC_FREE(memcredp);
                DEBUG(10,("winbindd_delete_memory_creds: "
                        "deleted entry for user %s\n",
                        username));
index ccea44acf185fc1ffa50f3d3fa36106f1b9b0ee7..0c1fc44efd792361123086db12af4ebf0b80621e 100644 (file)
@@ -1148,14 +1148,14 @@ void winbind_msg_onlinestatus(struct messaging_context *msg_ctx,
 
        message = collect_onlinestatus(mem_ctx);
        if (message == NULL) {
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
                return;
        }
 
        messaging_send_buf(msg_ctx, server_id, MSG_WINBIND_ONLINESTATUS,
                           (const uint8_t *)message, strlen(message) + 1);
 
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 }
 
 void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
@@ -1190,7 +1190,7 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
                message = NDR_PRINT_STRUCT_STRING(mem_ctx, winbindd_domain,
                                                  find_domain_from_name_noinit(domain));
                if (!message) {
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return;
                }
 
@@ -1198,7 +1198,7 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
                                   MSG_WINBIND_DUMP_DOMAIN_LIST,
                                   (const uint8_t *)message, strlen(message) + 1);
 
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
 
                return;
        }
@@ -1208,13 +1208,13 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
        for (dom = domain_list(); dom; dom=dom->next) {
                message = NDR_PRINT_STRUCT_STRING(mem_ctx, winbindd_domain, dom);
                if (!message) {
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return;
                }
 
                s = talloc_asprintf_append(s, "%s\n", message);
                if (!s) {
-                       talloc_destroy(mem_ctx);
+                       TALLOC_FREE(mem_ctx);
                        return;
                }
        }
@@ -1227,7 +1227,7 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
                nt_errstr(status)));
        }
 
-       talloc_destroy(mem_ctx);
+       TALLOC_FREE(mem_ctx);
 }
 
 static void account_lockout_policy_handler(struct tevent_context *ctx,
@@ -1987,7 +1987,7 @@ void winbindd_terminate(bool is_parent)
                char *description = talloc_describe_all(mem_ctx);
 
                DEBUG(3, ("tallocs left:\n%s\n", description));
-               talloc_destroy(mem_ctx);
+               TALLOC_FREE(mem_ctx);
        }
 #endif
 
index f7b68929bc912c8bc9645623223f353215a01740..2e86336322c540dc9f50a4eefdfdf4a55d6eb80e 100644 (file)
@@ -2434,7 +2434,7 @@ bool winbindd_can_contact_domain(struct winbindd_domain *domain)
        ret = true;
 
 done:
-       talloc_destroy(frame);
+       TALLOC_FREE(frame);
 
        return ret;
 }