From: Volker Lendecke Date: Fri, 17 Oct 2025 12:39:18 +0000 (+0200) Subject: s3: talloc_destroy() -> TALLOC_FREE() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38b76366888ab366c6ea13382f93b443cbee1e8e;p=thirdparty%2Fsamba.git s3: talloc_destroy() -> TALLOC_FREE() 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 Reviewed-by: Anoop C S --- diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index b29e8e4201a..5a7da2f90de 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -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 diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index 862ac6e18e4..c0974af5976 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -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); } /** diff --git a/source3/libads/ldap_user.c b/source3/libads/ldap_user.c index 40c87c833d3..05558e9fe74 100644 --- a/source3/libads/ldap_user.c +++ b/source3/libads/ldap_user.c @@ -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 diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 865a41ff618..544d1be67df 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -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; diff --git a/source3/locking/posix.c b/source3/locking/posix.c index e900132430d..b476869b7ee 100644 --- a/source3/locking/posix.c +++ b/source3/locking/posix.c @@ -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; } diff --git a/source3/modules/vfs_afsacl.c b/source3/modules/vfs_afsacl.c index 3dc80d3bddc..d2a75d563b1 100644 --- a/source3/modules/vfs_afsacl.c +++ b/source3/modules/vfs_afsacl.c @@ -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; } diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 73830d45fd6..1d9fb80b3e2 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -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; } diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 5b322c38baf..81f5f53962b 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -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); } diff --git a/source3/printing/nt_printing_tdb.c b/source3/printing/nt_printing_tdb.c index eddefe59e72..9702d27490b 100644 --- a/source3/printing/nt_printing_tdb.c +++ b/source3/printing/nt_printing_tdb.c @@ -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 ); } diff --git a/source3/registry/regfio.c b/source3/registry/regfio.c index a9b8ce8b7e4..5eab4f6c21f 100644 --- a/source3/registry/regfio.c +++ b/source3/registry/regfio.c @@ -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 ); } /******************************************************************* diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c index 696259a87bf..e80092bec89 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c @@ -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); diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index 292483273c1..042fbc52eff 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -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; } diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 53636608ef5..0ea20854296 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -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; } diff --git a/source3/smbd/ntquotas.c b/source3/smbd/ntquotas.c index dbbd2f7842c..d3e19490885 100644 --- a/source3/smbd/ntquotas.c +++ b/source3/smbd/ntquotas.c @@ -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); } diff --git a/source3/torture/torture.c b/source3/torture/torture.c index a9822381b26..afb0ba52ebc 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -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; } diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c index b25dfdc41d5..6d96b8ec533 100644 --- a/source3/torture/vfstest.c +++ b/source3/torture/vfstest.c @@ -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 */ diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index d49b7537e71..a335517c544 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -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; } diff --git a/source3/utils/net_ads_gpo.c b/source3/utils/net_ads_gpo.c index 12d8e22d972..ed80f049200 100644 --- a/source3/utils/net_ads_gpo.c +++ b/source3/utils/net_ads_gpo.c @@ -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; } diff --git a/source3/utils/net_groupmap.c b/source3/utils/net_groupmap.c index 4f36d450f8e..854cf40e3f9 100644 --- a/source3/utils/net_groupmap.c +++ b/source3/utils/net_groupmap.c @@ -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; } diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 20aa01da90f..99dde46bec5 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -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; } diff --git a/source3/utils/net_rpc_shell.c b/source3/utils/net_rpc_shell.c index f50233146b9..577c6661492 100644 --- a/source3/utils/net_rpc_shell.c +++ b/source3/utils/net_rpc_shell.c @@ -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; } diff --git a/source3/utils/net_rpc_trust.c b/source3/utils/net_rpc_trust.c index ef10bb4c078..7b33e2cc89f 100644 --- a/source3/utils/net_rpc_trust.c +++ b/source3/utils/net_rpc_trust.c @@ -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; } diff --git a/source3/utils/net_usershare.c b/source3/utils/net_usershare.c index 74588822434..bbb3283c536 100644 --- a/source3/utils/net_usershare.c +++ b/source3/utils/net_usershare.c @@ -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; } diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c index 47182894a66..ea7c56e6566 100644 --- a/source3/utils/sharesec.c +++ b/source3/utils/sharesec.c @@ -683,7 +683,7 @@ int main(int argc, const char *argv[]) done: gfree_all(); poptFreeContext(pc); - talloc_destroy(ctx); + TALLOC_FREE(ctx); return retval; } diff --git a/source3/winbindd/idmap_ad_nss.c b/source3/winbindd/idmap_ad_nss.c index 31202806214..c44149f9064 100644 --- a/source3/winbindd/idmap_ad_nss.c +++ b/source3/winbindd/idmap_ad_nss.c @@ -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); } diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index 65a5ae17596..eb79586a2ca 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -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; } } diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 3963881ca45..67003bb00fb 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -1777,7 +1777,7 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain, } out: - talloc_destroy(mem_ctx); + TALLOC_FREE(mem_ctx); return result; } diff --git a/source3/winbindd/winbindd_cred_cache.c b/source3/winbindd/winbindd_cred_cache.c index b250daeac78..04f04510d33 100644 --- a/source3/winbindd/winbindd_cred_cache.c +++ b/source3/winbindd/winbindd_cred_cache.c @@ -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)); diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index ccea44acf18..0c1fc44efd7 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -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 diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c index f7b68929bc9..2e86336322c 100644 --- a/source3/winbindd/winbindd_util.c +++ b/source3/winbindd/winbindd_util.c @@ -2434,7 +2434,7 @@ bool winbindd_can_contact_domain(struct winbindd_domain *domain) ret = true; done: - talloc_destroy(frame); + TALLOC_FREE(frame); return ret; }